Skip to content

Commit

Permalink
cargo fmt --all --check
Browse files Browse the repository at this point in the history
  • Loading branch information
manmen-mi committed Dec 8, 2024
1 parent e5f0a8f commit 275071b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ impl AppState {
})?;

// replacer for rustbook url
let url_replacer = base_url.as_ref().map(|url| {
UrlReplacer::new(url)
});
let url_replacer = base_url.as_ref().map(|url| UrlReplacer::new(url));

let dir_canonical_path = term::canonicalize("exercises");
let mut exercises = exercise_infos
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ mod init;
mod list;
mod run;
mod term;
mod watch;
mod url_replacer;
mod watch;

const CURRENT_FORMAT_VERSION: u8 = 1;

Expand Down
14 changes: 7 additions & 7 deletions src/url_replacer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub struct UrlReplacer {
base_url: String
base_url: String,
}

const EN_BASE_URL: &str = "https://doc.rust-lang.org/book";
Expand All @@ -13,9 +13,7 @@ impl UrlReplacer {
base_url.to_owned()
};

Self {
base_url: url
}
Self { base_url: url }
}

/// replace rustbook url
Expand All @@ -41,7 +39,6 @@ link: https://example.com/ch03-02-data-types.html";
assert_eq!(hint, replacer.replace(hint));
}


#[test]
fn replace_rustbook_url() {
let replacer = UrlReplacer::new(&String::from(TEST_DOMAIN));
Expand All @@ -50,9 +47,12 @@ link: https://example.com/ch03-02-data-types.html";
hints (...) lines (...)
link: https://doc.rust-lang.org/book/ch03-02-data-types.html";

assert_eq!("\
assert_eq!(
"\
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]
Expand Down

0 comments on commit 275071b

Please sign in to comment.