cargo fmt --all --check

This commit is contained in:
manmen-mi 2024-12-08 12:05:21 +09:00
parent e5f0a8f997
commit 275071b740
3 changed files with 9 additions and 11 deletions

View file

@ -83,9 +83,7 @@ impl AppState {
})?; })?;
// replacer for rustbook url // replacer for rustbook url
let url_replacer = base_url.as_ref().map(|url| { let url_replacer = base_url.as_ref().map(|url| UrlReplacer::new(url));
UrlReplacer::new(url)
});
let dir_canonical_path = term::canonicalize("exercises"); let dir_canonical_path = term::canonicalize("exercises");
let mut exercises = exercise_infos let mut exercises = exercise_infos

View file

@ -21,8 +21,8 @@ mod init;
mod list; mod list;
mod run; mod run;
mod term; mod term;
mod watch;
mod url_replacer; mod url_replacer;
mod watch;
const CURRENT_FORMAT_VERSION: u8 = 1; const CURRENT_FORMAT_VERSION: u8 = 1;

View file

@ -1,5 +1,5 @@
pub struct UrlReplacer { pub struct UrlReplacer {
base_url: String base_url: String,
} }
const EN_BASE_URL: &str = "https://doc.rust-lang.org/book"; const EN_BASE_URL: &str = "https://doc.rust-lang.org/book";
@ -13,9 +13,7 @@ impl UrlReplacer {
base_url.to_owned() base_url.to_owned()
}; };
Self { Self { base_url: url }
base_url: url
}
} }
/// replace rustbook url /// replace rustbook url
@ -41,7 +39,6 @@ link: https://example.com/ch03-02-data-types.html";
assert_eq!(hint, replacer.replace(hint)); assert_eq!(hint, replacer.replace(hint));
} }
#[test] #[test]
fn replace_rustbook_url() { fn replace_rustbook_url() {
let replacer = UrlReplacer::new(&String::from(TEST_DOMAIN)); let replacer = UrlReplacer::new(&String::from(TEST_DOMAIN));
@ -50,9 +47,12 @@ link: https://example.com/ch03-02-data-types.html";
hints (...) lines (...) hints (...) lines (...)
link: https://doc.rust-lang.org/book/ch03-02-data-types.html"; link: https://doc.rust-lang.org/book/ch03-02-data-types.html";
assert_eq!("\ assert_eq!(
"\
hints (...) lines (...) hints (...) lines (...)
link: https://doc.rust-kr.org/ch03-02-data-types.html", replacer.replace(hint)); link: https://doc.rust-kr.org/ch03-02-data-types.html",
replacer.replace(hint)
);
} }
#[test] #[test]