File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed
Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff 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| {
Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ const EN_BASE_URL: &str = "https://doc.rust-lang.org/book";
66
77impl 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 {
You can’t perform that action at this time.
0 commit comments