Skip to content

Commit 32cf884

Browse files
committed
add a note for str::bytes
1 parent fb32aaf commit 32cf884

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
@@ -758,7 +758,8 @@ declare_clippy_lint! {
758758
/// Instead of `.chars().enumerate()`, the correct iterator to use is `.char_indices()`, which yields byte indices.
759759
///
760760
/// This pattern is technically fine if the strings are known to only use the ASCII subset,
761-
/// but there is also no downside to just using `.char_indices()` directly.
761+
/// though in those cases it would be better to use `bytes()` directly to make the intent clearer,
762+
/// but there is also no downside to just using `.char_indices()` directly and supporting non-ASCII strings.
762763
///
763764
/// You may also want to read the [chapter on strings in the Rust Book](https://doc.rust-lang.org/book/ch08-02-strings.html)
764765
/// which goes into this in more detail.

0 commit comments

Comments
 (0)