Use text.contains instead of text.find

This commit is contained in:
blank X 2021-01-10 14:25:01 +07:00
parent 9eb433c815
commit 05cc8ed95b
3 changed files with 3 additions and 3 deletions

2
Cargo.lock generated
View File

@ -330,7 +330,7 @@ dependencies = [
[[package]] [[package]]
name = "mangafetchi" name = "mangafetchi"
version = "0.1.3" version = "0.1.4"
dependencies = [ dependencies = [
"quick-xml", "quick-xml",
"reqwest", "reqwest",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "mangafetchi" name = "mangafetchi"
version = "0.1.3" version = "0.1.4"
authors = ["blank X <theblankx@protonmail.com>"] authors = ["blank X <theblankx@protonmail.com>"]
edition = "2018" edition = "2018"

View File

@ -19,7 +19,7 @@ fn generate_slug(text: &str) -> String {
.replace(&['ỳ', 'ý', 'ỵ', 'ỷ', 'ỹ'][..], "y") .replace(&['ỳ', 'ý', 'ỵ', 'ỷ', 'ỹ'][..], "y")
.replace('đ', "d") .replace('đ', "d")
.replace(&['!', '@', '%', '^', '*', '(', ')', '+', '=', '<', '>', '?', '/', ',', '.', ':', ';', '\'', ' ', '"', '&', '#', '[', ']', '~', '-'][..], "_"); .replace(&['!', '@', '%', '^', '*', '(', ')', '+', '=', '<', '>', '?', '/', ',', '.', ':', ';', '\'', ' ', '"', '&', '#', '[', ']', '~', '-'][..], "_");
while text.find("__").is_some() { while text.contains("__") {
text = text.replace("__", "_"); text = text.replace("__", "_");
} }
text.trim_matches('_').to_string() text.trim_matches('_').to_string()