@@ -45,7 +45,7 @@ pub fn read_file(path: &Path) -> std::io::Result<Vec<u8>> {
4545/// read_file_with_eol(&path).unwrap();
4646/// ```
4747pub fn read_file_with_eol ( path : & Path ) -> std:: io:: Result < Option < Vec < u8 > > > {
48- let file_size = fs:: metadata ( & path) . map_or ( 1024 * 1024 , |m| m. len ( ) as usize ) ;
48+ let file_size = fs:: metadata ( path) . map_or ( 1024 * 1024 , |m| m. len ( ) as usize ) ;
4949 if file_size <= 3 {
5050 // this file is very likely almost empty... so nothing to do on it
5151 return Ok ( None ) ;
@@ -198,7 +198,7 @@ pub fn guess_language<P: AsRef<Path>>(buf: &[u8], path: P) -> (Option<LANG>, Str
198198 . unwrap_or_else ( || "" . to_string ( ) ) ;
199199 let from_ext = get_from_ext ( & ext) ;
200200
201- let mode = get_emacs_mode ( buf) . unwrap_or_else ( || "" . to_string ( ) ) ;
201+ let mode = get_emacs_mode ( buf) . unwrap_or_default ( ) ;
202202
203203 let from_mode = get_from_emacs_mode ( & mode) ;
204204
@@ -225,10 +225,7 @@ pub fn guess_language<P: AsRef<Path>>(buf: &[u8], path: P) -> (Option<LANG>, Str
225225 fake:: get_true ( & ext, & mode) . unwrap_or_else ( || lang_mode. get_name ( ) . to_string ( ) ) ,
226226 )
227227 } else {
228- (
229- None ,
230- fake:: get_true ( & ext, & mode) . unwrap_or_else ( || "" . to_string ( ) ) ,
231- )
228+ ( None , fake:: get_true ( & ext, & mode) . unwrap_or_default ( ) )
232229 }
233230}
234231
@@ -317,7 +314,7 @@ pub(crate) fn guess_file<S: ::std::hash::BuildHasher>(
317314
318315 if let Some ( parent) = current_path. parent ( ) {
319316 for p in possibilities. iter ( ) {
320- if p. starts_with ( & parent) && current_path != p {
317+ if p. starts_with ( parent) && current_path != p {
321318 new_possibilities. push ( p. clone ( ) ) ;
322319 }
323320 }
0 commit comments