Skip to content

Commit faab09d

Browse files
committed
cleanup typos, fix warnings from cargo check relating to al8n/fs4-rs#31
1 parent a434dde commit faab09d

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

wright/src/source_tracking/fragment.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ impl Fragment {
192192
self.advance_by_unchecked(bytes);
193193
}
194194

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.
197197
#[inline]
198198
pub fn advance_by_unchecked(&mut self, bytes: usize) {
199199
self.range.start += bytes;
@@ -212,8 +212,8 @@ impl Fragment {
212212
self.retain_unchecked(bytes);
213213
}
214214

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.
217217
#[inline]
218218
pub fn retain_unchecked(&mut self, bytes: usize) {
219219
self.range.end = self.range.start + bytes;

wright/src/source_tracking/immutable_string.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ impl ImmutableString {
7171
let (index, next) = char_indices.next()?;
7272

7373
// 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));
7975

8076
// Update the boolean based on the consumed character.
8177
last_was_newline = next == '\n';
@@ -147,8 +143,7 @@ impl Drop for ImmutableStringInner {
147143
match self {
148144
// Unlock locked files.
149145
ImmutableStringInner::LockedFile { locked_file, .. } => {
150-
locked_file
151-
.unlock()
146+
FileExt::unlock(locked_file)
152147
// Log the error if there is one,
153148
.map_err(|io_err: io::Error| eprintln!("{}", io_err))
154149
// Discard value of result

wright/src/source_tracking/source.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ impl Source {
147147

148148
// Handle success by finishing adding the file to the FileMap.
149149
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.
151151
// SAFETY: The file should be locked at this point so undefined behaviour from concurrent
152152
// modification is avoided.
153153
let mem_map: Mmap = unsafe {
154154
Mmap::map(&file)
155155
// Make sure we (at least try to) unlock the file if there's an issue memory mapping it.
156156
.inspect_err(|_| {
157-
file.unlock()
157+
FileExt::unlock(&file)
158158
.map_err(|err| eprintln!("Error unlocking file: {:?}", err))
159159
.ok();
160160
})
@@ -165,7 +165,7 @@ impl Source {
165165

166166
if let Err(utf8_error) = std::str::from_utf8(raw_data) {
167167
// The file is not valid for us so we should unlock it and return an error.
168-
file.unlock()
168+
FileExt::unlock(&file)
169169
.map_err(|err| eprintln!("Error unlocking file: {:?}", err))
170170
.ok();
171171

0 commit comments

Comments
 (0)