holy clippy

This commit is contained in:
manmen-mi 2024-12-08 11:50:49 +09:00
parent 027cbdb629
commit e5f0a8f997
2 changed files with 6 additions and 8 deletions

View file

@ -83,11 +83,9 @@ impl AppState {
})?; })?;
// replacer for rustbook url // replacer for rustbook url
let url_replacer = if let Some(url) = &base_url { let url_replacer = base_url.as_ref().map(|url| {
Some(UrlReplacer::new(&url)) UrlReplacer::new(url)
} else { });
None
};
let dir_canonical_path = term::canonicalize("exercises"); let dir_canonical_path = term::canonicalize("exercises");
let mut exercises = exercise_infos let mut exercises = exercise_infos
@ -102,7 +100,7 @@ impl AppState {
let mut hint = exercise_info.hint.leak().trim_ascii(); let mut hint = exercise_info.hint.leak().trim_ascii();
if let Some(replacer) = &url_replacer { if let Some(replacer) = &url_replacer {
hint = replacer.replace(&hint).leak(); hint = replacer.replace(hint).leak();
} }
let canonical_path = dir_canonical_path.as_deref().map(|dir_canonical_path| { let canonical_path = dir_canonical_path.as_deref().map(|dir_canonical_path| {

View file

@ -6,11 +6,11 @@ const EN_BASE_URL: &str = "https://doc.rust-lang.org/book";
impl UrlReplacer { impl UrlReplacer {
/// this fn will trim url end with '/' /// this fn will trim url end with '/'
pub fn new(base_url: &String) -> Self { pub fn new(base_url: &str) -> Self {
let url = if base_url.ends_with('/') { let url = if base_url.ends_with('/') {
base_url.trim_end_matches('/').to_owned() base_url.trim_end_matches('/').to_owned()
} else { } else {
base_url.clone() base_url.to_owned()
}; };
Self { Self {