@@ -40,11 +40,10 @@ impl SearchTerm {
4040}
4141
4242/// Remove special characteres that may cause errors when creating directories or files
43- fn remove_conflicting_characteres < T : AsRef < Path > > ( title : T ) -> PathBuf {
43+ fn remove_conflicting_characteres < T : AsRef < str > > ( title : T ) -> PathBuf {
4444 let invalid_chars = [ '\\' , '/' , ':' , '*' , '?' , '"' , '<' , '>' , '|' ] ;
4545
46- let title: & Path = title. as_ref ( ) ;
47- let title = title. to_str ( ) . unwrap ( ) . trim ( ) ;
46+ let title: & str = title. as_ref ( ) . trim ( ) ;
4847
4948 let sanitized_title: String = title. chars ( ) . map ( |c| if invalid_chars. contains ( & c) { '_' } else { c } ) . collect ( ) ;
5049
@@ -63,7 +62,7 @@ impl Display for SanitizedFilename {
6362}
6463
6564impl SanitizedFilename {
66- pub fn new < T : AsRef < Path > > ( name : T ) -> Self {
65+ pub fn new < T : AsRef < str > > ( name : T ) -> Self {
6766 Self ( remove_conflicting_characteres ( name) )
6867 }
6968
@@ -72,7 +71,7 @@ impl SanitizedFilename {
7271 }
7372}
7473
75- impl < T : AsRef < Path > > From < T > for SanitizedFilename {
74+ impl < T : AsRef < str > > From < T > for SanitizedFilename {
7675 fn from ( value : T ) -> Self {
7776 Self :: new ( value)
7877 }
@@ -161,7 +160,7 @@ mod test {
161160
162161 assert_eq ! ( Path :: new( "some name which contains _" ) , file_name. as_path( ) ) ;
163162
164- let file_name = SanitizedFilename :: new ( "some / name / which contains " ) ;
163+ let file_name = SanitizedFilename :: new ( " some / name / which contains " ) ;
165164
166165 assert_eq ! ( Path :: new( "some _ name _ which contains" ) , file_name. as_path( ) )
167166 }
0 commit comments