Skip to content

Commit

Permalink
Fail build on clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
indy256 committed Jan 19, 2025
1 parent 3b3465b commit 403257c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
run: |
cd rust
cargo fmt -- --check
RUSTFLAGS="-A unused" cargo clippy
RUSTFLAGS="-A unused" cargo clippy -- -Dwarnings
cargo clippy --tests
- name: compile and test
run: |
Expand Down
4 changes: 2 additions & 2 deletions rust/structures/mergeable_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod tests {
#[case(&mut [1, 1])]
#[case(&mut [3, 1, 2])]
fn basic_test(#[case] seq: &mut [u32]) {
let heap_sorted_values = sort_with_heap(&seq);
let heap_sorted_values = sort_with_heap(seq);
seq.sort();
assert_eq!(heap_sorted_values, seq);
}
Expand Down Expand Up @@ -92,7 +92,7 @@ mod tests {
}

fn sort_with_heap(seq: &[u32]) -> Vec<u32> {
let mut heap = seq.iter().fold(None, |h, v| Heap::insert(h, v));
let mut heap = seq.iter().fold(None, Heap::insert);
let mut heap_sorted_values = Vec::new();
while heap.is_some() {
let (updated_heap, min_value) = Heap::remove_min(heap);
Expand Down
7 changes: 5 additions & 2 deletions rust/structures/treap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<K: Copy + PartialOrd, V: Copy + PartialEq + AddAssign + Ord + Default> Trea
value,
mx: value,
add: V::default(),
prio: rand::thread_rng().gen_range(0..1000_000_000),
prio: rand::thread_rng().gen_range(0..1_000_000_000),
size: 1,
left: None,
right: None,
Expand Down Expand Up @@ -59,20 +59,23 @@ impl<K: Copy + PartialOrd, V: Copy + PartialEq + AddAssign + Ord + Default> Trea
node.as_ref().map_or(value, |t| max(t.mx, value))
}

#[allow(clippy::type_complexity)]
pub fn split(
root: Option<Box<Treap<K, V>>>,
min_right: K,
) -> (Option<Box<Treap<K, V>>>, Option<Box<Treap<K, V>>>) {
Self::inner_split(root, min_right, |a, b| a >= b)
}

#[allow(clippy::type_complexity)]
pub fn strict_split(
root: Option<Box<Treap<K, V>>>,
min_right: K,
) -> (Option<Box<Treap<K, V>>>, Option<Box<Treap<K, V>>>) {
Self::inner_split(root, min_right, |a, b| a > b)
}

#[allow(clippy::type_complexity)]
fn inner_split<F: Fn(K, K) -> bool>(
root: Option<Box<Treap<K, V>>>,
min_right: K,
Expand Down Expand Up @@ -139,6 +142,7 @@ impl<K: Copy + PartialOrd, V: Copy + PartialEq + AddAssign + Ord + Default> Trea
) -> Option<Box<Treap<K, V>>> {
let (l1, r1) = Self::strict_split(root, rr);
let (l2, mut r2) = Self::split(l1, ll);
#[allow(clippy::option_map_unit_fn)]
r2.as_mut().map(|t| t.apply(delta));
Self::merge(Self::merge(l2, r2), r1)
}
Expand Down Expand Up @@ -167,7 +171,6 @@ mod tests {
treap = Treap::modify(treap, 1, 2, 100);

let (t, q2) = Treap::query(treap, 1, 2);
treap = t;
assert_eq!(q2, 120);
}
}

0 comments on commit 403257c

Please sign in to comment.