Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Jan 18, 2024
1 parent feb8c07 commit 42d9fb9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Tests

on:
# TODO: remove
push:
branches:
- main
Expand Down
2 changes: 2 additions & 0 deletions src/bloom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ impl BloomFilter {
for i in 0..(self.k as u64) {
let idx = h1 % (self.m as u64);

// NOTE: should be in bounds because of modulo
#[allow(clippy::expect_used)]
if !self.inner.get(idx as usize).expect("should be in bounds") {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub const BLOOM_FILTER_FILE: &str = "bloom";
/// Atomically rewrites a file
pub fn rewrite_atomic<P: AsRef<Path>>(path: P, content: &[u8]) -> std::io::Result<()> {
let path = path.as_ref();
let folder = path.parent().expect("should have parent folder");
let folder = path.parent().expect("should have a parent");

let mut temp_file = tempfile::NamedTempFile::new_in(folder)?;
temp_file.write_all(content)?;
Expand Down
1 change: 1 addition & 0 deletions src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fn to_base36(mut x: u32) -> String {
x /= BASE_36_RADIX;

result.push(std::char::from_digit(m, BASE_36_RADIX).expect("should be hex digit"));

if x == 0 {
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
pub fn unix_timestamp() -> std::time::Duration {
let now = std::time::SystemTime::now();

// NOTE: Unwrap is trivial
#[allow(clippy::unwrap_used)]
// NOTE: Expect is trivial
#[allow(clippy::expect_used)]
now.duration_since(std::time::SystemTime::UNIX_EPOCH)
.unwrap()
.expect("time went backwards")
}

0 comments on commit 42d9fb9

Please sign in to comment.