Closed samueltardieu closed 1 month ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 97.03%. Comparing base (
7c0024a
) to head (bed207e
). Report is 7 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Thanks for the PR!
String::len()
already returns the number of bytes in the string.
This is true but I would argue that the way the code is currently written is clearer and perhaps {str
/String
}::len()
shouldn't exist. Since the current code passes Clippy I am inclined to leave it as-is and I hope Clippy doesn't start warning about this pattern.
WDYT?
I totally agree that {String
, str
}::len()
should not exist in the first place. But they do, and I think using .as_bytes().len()
adds to the confusion, not at the place where it is used, but everywhere else: it may let people think that this is necessary, and that len()
alone would return the number of codepoints.
This is why I prefer to use the function directly and have a clippy lint (which can be disabled of course, at a local or project level) to warn people that this is unnecessary because precisely len()
is weirdly defined on strings.
I think this is just a matter of taste that's not worth working on so I'm going to close it. I appreciate the effort though.
String::len()
already returns the number of bytes in the string.