@@ -28,18 +28,18 @@ impl XMLUtil {
2828 Self :: snr_xml ( Mode :: Value , dir, src_file, None , Some ( pattern) , None , None ) ;
2929 }
3030
31- pub fn replace_xml ( dir : & str , src_file : & str , pattern : & str , replace : & str , output_file : & Option < String > ) {
31+ pub fn replace_xml ( dir : & str , src_file : & str , pattern : & str , replace : & str , output_file : & Option < & str > ) {
3232 let out_file = match output_file {
33- Some ( of) => of. as_str ( ) ,
33+ Some ( of) => of,
3434 None => src_file
3535 } ;
3636
3737 Self :: snr_xml ( Mode :: Value , dir, src_file, Some ( vec ! ( "word/document.xml" ) ) , Some ( pattern) , Some ( replace) , Some ( out_file) ) ;
3838 }
3939
40- pub fn replace_attr ( dir : & str , src_file : & str , pattern : & str , replace : & str , output_file : & Option < String > ) {
40+ pub fn replace_attr ( dir : & str , src_file : & str , pattern : & str , replace : & str , output_file : & Option < & str > ) {
4141 let out_file = match output_file {
42- Some ( of) => of. as_str ( ) ,
42+ Some ( of) => of,
4343 None => src_file
4444 } ;
4545
@@ -251,7 +251,8 @@ mod tests {
251251 assert ! ( !before. contains( "zzz" ) , "Precondition" ) ;
252252
253253 XMLUtil :: replace_xml ( & testdir. to_string_lossy ( ) , "my-source.docx" ,
254- "[Ss]ome" , "zzz" , & None ) ;
254+ "[Ss]ome" , "zzz" ,
255+ & Some ( & testdir. join ( "output.docx" ) . to_string_lossy ( ) ) ) ;
255256
256257 // Check that the replacement worked as expected
257258 let after = fs:: read_to_string ( testdir. join ( "word/document.xml" ) ) ?;
@@ -279,7 +280,8 @@ mod tests {
279280 assert ! ( before_doc. contains( ">www.example.com<" ) , "Precondition" ) ;
280281
281282 XMLUtil :: replace_attr ( & testdir. to_string_lossy ( ) , "my-source.docx" ,
282- "www.example.com" , "foobar.org" , & None ) ;
283+ "www.example.com" , "foobar.org" ,
284+ & Some ( & testdir. join ( "output-2.docx" ) . to_string_lossy ( ) ) ) ;
283285
284286 let after_doc = fs:: read_to_string ( "./src/test/test_tree2/word/document.xml" ) ?;
285287 let after = fs:: read_to_string ( testdir. join ( "word/_rels/document.xml.rels" ) ) ?;
0 commit comments