From 32cf88450bd1d97a1ec1cfcb67c04173ea92db3c Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Tue, 3 Dec 2024 04:24:56 +0100 Subject: [PATCH] add a note for `str::bytes` --- clippy_lints/src/loops/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 10ba739909f7..9a3fd147fb55 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -758,7 +758,8 @@ declare_clippy_lint! { /// Instead of `.chars().enumerate()`, the correct iterator to use is `.char_indices()`, which yields byte indices. /// /// This pattern is technically fine if the strings are known to only use the ASCII subset, - /// but there is also no downside to just using `.char_indices()` directly. + /// though in those cases it would be better to use `bytes()` directly to make the intent clearer, + /// but there is also no downside to just using `.char_indices()` directly and supporting non-ASCII strings. /// /// You may also want to read the [chapter on strings in the Rust Book](https://doc.rust-lang.org/book/ch08-02-strings.html) /// which goes into this in more detail.