@@ -170,6 +170,12 @@ impl fmt::Display for Error {
170
170
}
171
171
}
172
172
173
+ impl < U > Default for Vfs < U > {
174
+ fn default ( ) -> Self {
175
+ Self :: new ( )
176
+ }
177
+ }
178
+
173
179
impl < U > Vfs < U > {
174
180
/// Creates a new, empty VFS.
175
181
pub fn new ( ) -> Vfs < U > {
@@ -558,7 +564,7 @@ impl<T: FileLoader, U> VfsInternal<T, U> {
558
564
let mut files = self . files . lock ( ) . unwrap ( ) ;
559
565
match files. get_mut ( path) {
560
566
Some ( ref mut file) => {
561
- if let None = file. user_data {
567
+ if file. user_data . is_none ( ) {
562
568
let text = match file. kind {
563
569
FileKind :: Text ( ref f) => Some ( & f. text as & str ) ,
564
570
FileKind :: Binary ( _) => None ,
@@ -587,7 +593,7 @@ fn coalesce_changes<'a>(changes: &'a [Change]) -> HashMap<&'a Path, Vec<&'a Chan
587
593
// Note that for any given file, we preserve the order of the changes.
588
594
let mut result = HashMap :: new ( ) ;
589
595
for c in changes {
590
- result. entry ( & * c. file ( ) ) . or_insert ( vec ! [ ] ) . push ( c) ;
596
+ result. entry ( & * c. file ( ) ) . or_insert_with ( Vec :: new ) . push ( c) ;
591
597
}
592
598
result
593
599
}
@@ -735,7 +741,7 @@ impl TextFile {
735
741
new_text. push_str ( & self . text [ range. 1 as usize ..] ) ;
736
742
new_text
737
743
}
738
- Change :: AddFile { file : _ , ref text } => text. to_owned ( ) ,
744
+ Change :: AddFile { ref text, .. } => text. to_owned ( ) ,
739
745
} ;
740
746
741
747
self . text = new_text;
@@ -823,7 +829,7 @@ fn byte_in_str(s: &str, c: span::Column<span::ZeroIndexed>) -> Result<usize, Err
823
829
}
824
830
}
825
831
826
- return Err ( Error :: InternalError ( "Out of bounds access in `byte_in_str`" ) ) ;
832
+ Err ( Error :: InternalError ( "Out of bounds access in `byte_in_str`" ) )
827
833
}
828
834
829
835
/// Return a UTF-8 byte offset in `s` for a given UTF-16 code unit offset.
@@ -842,7 +848,7 @@ fn byte_in_str_utf16(s: &str, c: span::Column<span::ZeroIndexed>) -> Result<usiz
842
848
utf16_offset += chr. len_utf16 ( ) ;
843
849
}
844
850
845
- return Err ( Error :: InternalError ( "UTF-16 code unit offset is not at `str` char boundary" ) ) ;
851
+ Err ( Error :: InternalError ( "UTF-16 code unit offset is not at `str` char boundary" ) )
846
852
}
847
853
848
854
trait FileLoader {
@@ -864,7 +870,7 @@ impl FileLoader for RealFileLoader {
864
870
}
865
871
} ;
866
872
let mut buf = vec ! [ ] ;
867
- if let Err ( _ ) = file. read_to_end ( & mut buf) {
873
+ if file. read_to_end ( & mut buf) . is_err ( ) {
868
874
return Err ( Error :: Io (
869
875
Some ( file_name. to_owned ( ) ) ,
870
876
Some ( format ! ( "Could not read file: {}" , file_name. display( ) ) ) ,
0 commit comments