Skip to content

Commit e5f0a8f

Browse files
committed
holy clippy
1 parent 027cbdb commit e5f0a8f

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/app_state.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,9 @@ impl AppState {
8383
})?;
8484

8585
// replacer for rustbook url
86-
let url_replacer = if let Some(url) = &base_url {
87-
Some(UrlReplacer::new(&url))
88-
} else {
89-
None
90-
};
86+
let url_replacer = base_url.as_ref().map(|url| {
87+
UrlReplacer::new(url)
88+
});
9189

9290
let dir_canonical_path = term::canonicalize("exercises");
9391
let mut exercises = exercise_infos
@@ -102,7 +100,7 @@ impl AppState {
102100
let mut hint = exercise_info.hint.leak().trim_ascii();
103101

104102
if let Some(replacer) = &url_replacer {
105-
hint = replacer.replace(&hint).leak();
103+
hint = replacer.replace(hint).leak();
106104
}
107105

108106
let canonical_path = dir_canonical_path.as_deref().map(|dir_canonical_path| {

src/url_replacer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ const EN_BASE_URL: &str = "https://doc.rust-lang.org/book";
66

77
impl UrlReplacer {
88
/// this fn will trim url end with '/'
9-
pub fn new(base_url: &String) -> Self {
9+
pub fn new(base_url: &str) -> Self {
1010
let url = if base_url.ends_with('/') {
1111
base_url.trim_end_matches('/').to_owned()
1212
} else {
13-
base_url.clone()
13+
base_url.to_owned()
1414
};
1515

1616
Self {

0 commit comments

Comments
 (0)