Skip to content

Commit

Permalink
cleanup typos, fix warnings from cargo check relating to al8n/fs4-r…
Browse files Browse the repository at this point in the history
  • Loading branch information
vcfxb committed Jan 31, 2025
1 parent a434dde commit faab09d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
8 changes: 4 additions & 4 deletions wright/src/source_tracking/fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ impl Fragment {
self.advance_by_unchecked(bytes);
}

/// This is the same as [Fragment::advance_by] except without the bounds checking. Use carefully or the created
/// [Fragment]s will be invalid.
/// This is the same as [Fragment::advance_by] except without the bounds checking. Use carefully or the updated
/// [Fragment] will be invalid.
#[inline]
pub fn advance_by_unchecked(&mut self, bytes: usize) {
self.range.start += bytes;
Expand All @@ -212,8 +212,8 @@ impl Fragment {
self.retain_unchecked(bytes);
}

/// This is the same as [Fragment::retain] except without the bounds checking. Use carefully or the created
/// [Fragment]s will be invalid.
/// This is the same as [Fragment::retain] except without the bounds checking. Use carefully or the updated
/// [Fragment] will be invalid.
#[inline]
pub fn retain_unchecked(&mut self, bytes: usize) {
self.range.end = self.range.start + bytes;
Expand Down
9 changes: 2 additions & 7 deletions wright/src/source_tracking/immutable_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ impl ImmutableString {
let (index, next) = char_indices.next()?;

// Determine whether to list this character's index as starting a new line.
let result = if last_was_newline {
Some(Some(index))
} else {
Some(None)
};
let result = Some(last_was_newline.then_some(index));

// Update the boolean based on the consumed character.
last_was_newline = next == '\n';
Expand Down Expand Up @@ -147,8 +143,7 @@ impl Drop for ImmutableStringInner {
match self {
// Unlock locked files.
ImmutableStringInner::LockedFile { locked_file, .. } => {
locked_file
.unlock()
FileExt::unlock(locked_file)
// Log the error if there is one,
.map_err(|io_err: io::Error| eprintln!("{}", io_err))
// Discard value of result
Expand Down
6 changes: 3 additions & 3 deletions wright/src/source_tracking/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ impl Source {

// Handle success by finishing adding the file to the FileMap.
Ok(ChannelMessage::FileLocked(file)) => {
// The file is now locked, we can memmory map it and add it ro the vec.
// The file is now locked, we can memmory map it and add it to the vec.
// SAFETY: The file should be locked at this point so undefined behaviour from concurrent
// modification is avoided.
let mem_map: Mmap = unsafe {
Mmap::map(&file)
// Make sure we (at least try to) unlock the file if there's an issue memory mapping it.
.inspect_err(|_| {
file.unlock()
FileExt::unlock(&file)
.map_err(|err| eprintln!("Error unlocking file: {:?}", err))
.ok();
})
Expand All @@ -165,7 +165,7 @@ impl Source {

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

Expand Down

0 comments on commit faab09d

Please sign in to comment.