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
|
||||
let url_replacer = if let Some(url) = &base_url {
|
||||
Some(UrlReplacer::new(&url))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let url_replacer = base_url.as_ref().map(|url| {
|
||||
UrlReplacer::new(url)
|
||||
});
|
||||
|
||||
let dir_canonical_path = term::canonicalize("exercises");
|
||||
let mut exercises = exercise_infos
|
||||
|
@ -102,7 +100,7 @@ impl AppState {
|
|||
let mut hint = exercise_info.hint.leak().trim_ascii();
|
||||
|
||||
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| {
|
||||
|
|
|
@ -6,11 +6,11 @@ const EN_BASE_URL: &str = "https://doc.rust-lang.org/book";
|
|||
|
||||
impl UrlReplacer {
|
||||
/// 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('/') {
|
||||
base_url.trim_end_matches('/').to_owned()
|
||||
} else {
|
||||
base_url.clone()
|
||||
base_url.to_owned()
|
||||
};
|
||||
|
||||
Self {
|
||||
|
|
Loading…
Reference in a new issue