File tree 3 files changed +9
-14
lines changed
wright/src/source_tracking
3 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -192,8 +192,8 @@ impl Fragment {
192
192
self . advance_by_unchecked ( bytes) ;
193
193
}
194
194
195
- /// This is the same as [Fragment::advance_by] except without the bounds checking. Use carefully or the created
196
- /// [Fragment]s will be invalid.
195
+ /// This is the same as [Fragment::advance_by] except without the bounds checking. Use carefully or the updated
196
+ /// [Fragment] will be invalid.
197
197
#[ inline]
198
198
pub fn advance_by_unchecked ( & mut self , bytes : usize ) {
199
199
self . range . start += bytes;
@@ -212,8 +212,8 @@ impl Fragment {
212
212
self . retain_unchecked ( bytes) ;
213
213
}
214
214
215
- /// This is the same as [Fragment::retain] except without the bounds checking. Use carefully or the created
216
- /// [Fragment]s will be invalid.
215
+ /// This is the same as [Fragment::retain] except without the bounds checking. Use carefully or the updated
216
+ /// [Fragment] will be invalid.
217
217
#[ inline]
218
218
pub fn retain_unchecked ( & mut self , bytes : usize ) {
219
219
self . range . end = self . range . start + bytes;
Original file line number Diff line number Diff line change @@ -71,11 +71,7 @@ impl ImmutableString {
71
71
let ( index, next) = char_indices. next ( ) ?;
72
72
73
73
// Determine whether to list this character's index as starting a new line.
74
- let result = if last_was_newline {
75
- Some ( Some ( index) )
76
- } else {
77
- Some ( None )
78
- } ;
74
+ let result = Some ( last_was_newline. then_some ( index) ) ;
79
75
80
76
// Update the boolean based on the consumed character.
81
77
last_was_newline = next == '\n' ;
@@ -147,8 +143,7 @@ impl Drop for ImmutableStringInner {
147
143
match self {
148
144
// Unlock locked files.
149
145
ImmutableStringInner :: LockedFile { locked_file, .. } => {
150
- locked_file
151
- . unlock ( )
146
+ FileExt :: unlock ( locked_file)
152
147
// Log the error if there is one,
153
148
. map_err ( |io_err : io:: Error | eprintln ! ( "{}" , io_err) )
154
149
// Discard value of result
Original file line number Diff line number Diff line change @@ -147,14 +147,14 @@ impl Source {
147
147
148
148
// Handle success by finishing adding the file to the FileMap.
149
149
Ok ( ChannelMessage :: FileLocked ( file) ) => {
150
- // The file is now locked, we can memmory map it and add it ro the vec.
150
+ // The file is now locked, we can memmory map it and add it to the vec.
151
151
// SAFETY: The file should be locked at this point so undefined behaviour from concurrent
152
152
// modification is avoided.
153
153
let mem_map: Mmap = unsafe {
154
154
Mmap :: map ( & file)
155
155
// Make sure we (at least try to) unlock the file if there's an issue memory mapping it.
156
156
. inspect_err ( |_| {
157
- file . unlock ( )
157
+ FileExt :: unlock ( & file )
158
158
. map_err ( |err| eprintln ! ( "Error unlocking file: {:?}" , err) )
159
159
. ok ( ) ;
160
160
} )
@@ -165,7 +165,7 @@ impl Source {
165
165
166
166
if let Err ( utf8_error) = std:: str:: from_utf8 ( raw_data) {
167
167
// The file is not valid for us so we should unlock it and return an error.
168
- file . unlock ( )
168
+ FileExt :: unlock ( & file )
169
169
. map_err ( |err| eprintln ! ( "Error unlocking file: {:?}" , err) )
170
170
. ok ( ) ;
171
171
You can’t perform that action at this time.
0 commit comments