Lint suggestion: Replace .chars().enumerate()
with .char_indices()
when index is used in subsequent string slice operations
#10202
Labels
A-lint
Area: New lints
What it does
Suggest instances where
.chars().enumerate()
should be replaced with.char_indices()
instead for str slices when the index returned by.enumerate()
is used in subsequent string slice operations likes[i..]
ors.split_at(i)
.Here is a real world example of this kind of issue: RustPython/RustPython#4444, failure to correctly handle multi-byte character when doing string slice operations leads to panic at runtime.
Lint Name
No response
Category
correctness
Advantage
Drawbacks
No response
Example
Playground
The text was updated successfully, but these errors were encountered: