mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-25 23:10:30 +00:00
holy clippy
This commit is contained in:
parent
027cbdb629
commit
e5f0a8f997
2 changed files with 6 additions and 8 deletions
|
@ -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| {
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue