Skip to content

Commit

Permalink
are you happy clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanPleshkov committed Jan 16, 2024
1 parent 12a9718 commit 4cae86c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl Wal {
// Validate the closed segments. They must be non-overlapping, and contiguous.
closed_segments.sort_by(|a, b| a.start_index.cmp(&b.start_index));
let mut next_start_index = closed_segments
.get(0)
.first()
.map_or(0, |segment| segment.start_index);
for &ClosedSegment {
start_index,
Expand Down Expand Up @@ -394,7 +394,7 @@ impl Wal {
if until
<= self
.closed_segments
.get(0)
.first()
.map_or(0, |segment| segment.start_index)
{
// Do nothing, the first entry is already greater than `until`.
Expand Down Expand Up @@ -450,15 +450,15 @@ impl Wal {
self.open_segment_start_index()
- self
.closed_segments
.get(0)
.first()
.map_or(0, |segment| segment.start_index)
+ self.open_segment.segment.len() as u64
}

/// The index of the first entry.
pub fn first_index(&self) -> u64 {
self.closed_segments
.get(0)
.first()
.map_or(0, |segment| segment.start_index)
}

Expand Down Expand Up @@ -523,7 +523,7 @@ impl fmt::Debug for Wal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let start_index = self
.closed_segments
.get(0)
.first()
.map_or(0, |segment| segment.start_index);
let end_index = self.open_segment_start_index() + self.open_segment.segment.len() as u64;
write!(
Expand Down
7 changes: 7 additions & 0 deletions src/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,13 @@ impl Segment {
where
P: AsRef<Path>,
{
if path.as_ref().exists() {
return Err(Error::new(
ErrorKind::AlreadyExists,
format!("Path {:?} already exists", path.as_ref()),
));
}

let mut other = Self::create(path, self.capacity())?;
unsafe {
other
Expand Down

0 comments on commit 4cae86c

Please sign in to comment.