use strip_prefix() instead of starts_with and slicing (clippy::manual_strip)

This commit is contained in:
Matthias Krüger 2021-03-21 12:38:21 +01:00
parent 3d9b3a8575
commit 8a67116857
4 changed files with 9 additions and 13 deletions

View file

@ -154,8 +154,8 @@ fn hide_hash_comments(text: &str) -> String {
fn reveal_hash_comments(text: &str) -> String {
text.split('\n') // want final newline
.map(|it| {
if it.starts_with("# ") {
&it[2..]
if let Some(stripped) = it.strip_prefix("# ") {
stripped
} else if it == "#" {
""
} else {