From: Guillaume Gomez Date: Sat, 3 Oct 2020 13:43:04 +0000 (+0200) Subject: Use char_indices() instead of chars() to prevent more than one-byte characters issue X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=ca199b16e5c06c28b3d35de79ffaaff81bd0d43f;p=rust.git Use char_indices() instead of chars() to prevent more than one-byte characters issue --- diff --git a/src/librustdoc/passes/html_tags.rs b/src/librustdoc/passes/html_tags.rs index f8869a41eb6..4218717c436 100644 --- a/src/librustdoc/passes/html_tags.rs +++ b/src/librustdoc/passes/html_tags.rs @@ -46,9 +46,7 @@ fn drop_tag( f: &impl Fn(&str, &Range), ) { let tag_name_low = tag_name.to_lowercase(); - if let Some(pos) = tags.iter().rev().position(|(t, _)| t.to_lowercase() == tag_name_low) { - // Because this is from a `rev` iterator, the position is reversed as well! - let pos = tags.len() - 1 - pos; + if let Some(pos) = tags.iter().rposition(|(t, _)| t.to_lowercase() == tag_name_low) { // If the tag is nested inside a "