You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit fixes an issue with `convert_case` crate reported in [1].
The issue is that the default implementation of `is_case` provided by
that crate initializes the converter with almost all available
boundaries.
As a result the following conversion takes place:
"ERR1".to_case(Case::UpperSnake) -> "ERR_1"
Furthermore, the following check fails, while it seems like it
shouldn't because the string is in capital letters.
"ERR1".is_case(Case::UpperSnake)
This commit introduces a new primitive `convert_case` which receives two
case parameters, one for the source case and one of the target case.
This way the converter is initialized with the correct source case
boundaries. And it allows implementation of a new `is_case` primitive
that builds on `convert_case` to select the source case boundaries
correctly.
[1] rutrum/convert-case#21
r-bk
added a commit
to r-bk/tighterror
that referenced
this issue
Jul 19, 2024
This commit fixes an issue with `convert_case` crate reported in [1].
The issue is that the default implementation of `is_case` provided by
that crate initializes the converter with almost all available
boundaries.
As a result the following conversion takes place:
"ERR1".to_case(Case::UpperSnake) -> "ERR_1"
Furthermore, the following check fails, while it seems like it
shouldn't because the string is in capital letters.
"ERR1".is_case(Case::UpperSnake)
This commit introduces a new primitive `convert_case` which receives two
case parameters, one for the source case and one of the target case.
This way the converter is initialized with the correct source case
boundaries. And it allows implementation of a new `is_case` primitive
that builds on `convert_case` to select the source case boundaries
correctly.
[1] rutrum/convert-case#21
@rutrum Hi!
Firstly, thanks for such a useful crate!
I have found the following example which IMO has a not intuitive result.
This test fails, even though
UpperSnake
case has only a single boundary_
and the string is in capital letters.This happens because the implementation of
is_case
initializes theStateConverter
withBoundary::defaults()
which includesUpperDigit
boundary.Is this by design, or a bug?
If a bug, would the correct implementation of
is_case
be something like this?The text was updated successfully, but these errors were encountered: