-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove regex requirement #876
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #876 +/- ##
==========================================
- Coverage 68.36% 68.32% -0.05%
==========================================
Files 128 128
Lines 15833 15811 -22
==========================================
- Hits 10825 10803 -22
Misses 5008 5008
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to write tests to ensure that the new implementation works as expected.
.position(|x| !x.is_numeric()) | ||
.map(|index| coin_str.split_at(index)) | ||
.filter(|(amount, denom)| !amount.is_empty() && !denom.is_empty()) | ||
.filter(|(_, denom)| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think filter means that you will exclude the invalid characters, but the result would be valid. In the original case, invalid characters will cause the method to fail.
.filter(|(amount, denom)| !amount.is_empty() && !denom.is_empty()) | ||
.filter(|(_, denom)| { | ||
!denom.contains(|x| { | ||
!matches!(x, 'a'..='z' | 'A'..='Z' | '0'..='9' | '/' | ':' | '\\' | '.' | '_' | '-') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think \\
was used as an escape for \
, which is an escape for .
in the original regex.
Yea. Tests are coming 🙂 I wanted to confirm the parsing logic before that. |
Co-authored-by: Farhad Shabani <Farhad.Shabani@gmail.com> Signed-off-by: Rano | Ranadeep <ranadip.bswas@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job @rnbguy. Thanks 👌🏻
* regex dep over safe-regex * new error variant * refactor regex use * coin parser wo regex * rm regex dep * fix incorrect conditions * add Coin::new * rm blackslash from valid charset * rewrite coin tests using rstest * fix broken test for denom with backslash * add name to testcases and add new tests * expect test panic message * addd tests with plus sign * update regex comment * simplify impl logic * implicit from_str * slash delim test * add changelog entry * version bump for ref link Co-authored-by: Farhad Shabani <Farhad.Shabani@gmail.com> Signed-off-by: Rano | Ranadeep <ranadip.bswas@gmail.com> * refactor denom parsing * refactor tests without Coin::new * rm Coin::new * nit --------- Signed-off-by: Rano | Ranadeep <ranadip.bswas@gmail.com> Co-authored-by: Farhad Shabani <Farhad.Shabani@gmail.com>
Closes: #875
Description
safe_regex
which is breaking our docsrs buildsPR author checklist:
unclog
.docs/
).Reviewer checklist:
Files changed
in the GitHub PR explorer.