rustlings/src/url_replacer.rs

18 lines
333 B
Rust
Raw Normal View History

2024-12-07 13:01:18 +00:00
pub struct UrlReplacer {
base_url: String
2024-12-07 12:40:18 +00:00
}
const EN_BASE_URL: &str = "https://doc.rust-lang.org/book";
2024-12-07 13:01:18 +00:00
impl UrlReplacer {
pub fn new(base_url: String) -> Self {
2024-12-07 12:40:18 +00:00
Self {
base_url
}
}
pub fn replace(&self, hint: &str) -> String {
2024-12-07 13:01:18 +00:00
hint.replace(EN_BASE_URL, &self.base_url)
2024-12-07 12:40:18 +00:00
}
}