Skip to content

Commit fc5538b

Browse files
committed
add a note for str::bytes
1 parent 192f94e commit fc5538b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clippy_lints/src/loops/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,8 @@ declare_clippy_lint! {
732732
/// Instead of `.chars().enumerate()`, the correct iterator to use is `.char_indices()`, which yields byte indices.
733733
///
734734
/// This pattern is technically fine if the strings are known to only use the ASCII subset,
735-
/// but there is also no downside to just using `.char_indices()` directly.
735+
/// though in those cases it would be better to use `bytes()` directly to make the intent clearer,
736+
/// but there is also no downside to just using `.char_indices()` directly and supporting non-ASCII strings.
736737
///
737738
/// You may also want to read the [chapter on strings in the Rust Book](https://doc.rust-lang.org/book/ch08-02-strings.html)
738739
/// which goes into this in more detail.

0 commit comments

Comments
 (0)