diff options
| author | Philipp Hansch <dev@phansch.net> | 2021-04-14 06:30:51 +0200 |
|---|---|---|
| committer | Philipp Hansch <dev@phansch.net> | 2021-04-14 06:30:51 +0200 |
| commit | cbdebd97ec4846391dc0f9a1288a3ab1fc053f99 (patch) | |
| tree | 9a1b70b3c36b95a4357b72f7fc8775abe2bbf3ff | |
| parent | 47a4865406ec748729a6e7ec23e5a4d5f9b88230 (diff) | |
| download | rust-cbdebd97ec4846391dc0f9a1288a3ab1fc053f99.tar.gz rust-cbdebd97ec4846391dc0f9a1288a3ab1fc053f99.zip | |
Explain why we use `char_indices()` instead of `chars()`
| -rw-r--r-- | clippy_lints/src/tabs_in_doc_comments.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clippy_lints/src/tabs_in_doc_comments.rs b/clippy_lints/src/tabs_in_doc_comments.rs index 51581b75ce3..1995981b905 100644 --- a/clippy_lints/src/tabs_in_doc_comments.rs +++ b/clippy_lints/src/tabs_in_doc_comments.rs @@ -104,6 +104,9 @@ fn get_chunks_of_tabs(the_str: &str) -> Vec<(u32, u32)> { // tracker to decide if the last group of tabs is not closed by a non-tab character let mut is_active = false; + // Note that we specifically need the char _byte_ indices here, not the positional indexes + // within the char array to deal with multi-byte characters properly. `char_indices` does + // exactly that. It provides an iterator over tuples of the form `(byte position, char)`. let char_indices: Vec<_> = the_str.char_indices().collect(); if let [(_, '\t')] = char_indices.as_slice() { |
