Skip to content

Commit

Permalink
Clippy lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianmarco Garrisi committed Feb 29, 2024
1 parent 42cc0e0 commit 2d1998b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
20 changes: 9 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
//! assert_eq!(pq.peek(), Some((&"Bananas", &25)));
//!
//! for (item, _) in pq.into_sorted_iter() {
//! println!("{}", item);
//! println!("{}", item); // Will print Bananas, Strawberries, Apples
//! }
//! ```
//!
Expand All @@ -70,19 +70,17 @@
//! use priority_queue::PriorityQueue;
//! use std::cmp::Reverse;
//!
//! fn main() {
//! let mut pq = PriorityQueue::new();
//! let mut pq = PriorityQueue::new();
//!
//! assert!(pq.is_empty());
//! pq.push("Apples", Reverse(5));
//! pq.push("Bananas", Reverse(8));
//! pq.push("Strawberries", Reverse(23));
//! assert!(pq.is_empty());
//! pq.push("Apples", Reverse(5));
//! pq.push("Bananas", Reverse(8));
//! pq.push("Strawberries", Reverse(23));
//!
//! assert_eq!(pq.peek(), Some((&"Apples", &Reverse(5))));
//! assert_eq!(pq.peek(), Some((&"Apples", &Reverse(5))));
//!
//! for (item, _) in pq.into_sorted_iter() {
//! println!("{}", item);
//! }
//! for (item, _) in pq.into_sorted_iter() {
//! println!("{}", item); // Will print Apples, Bananas, Strawberries
//! }
//! ```
Expand Down
10 changes: 5 additions & 5 deletions tests/double_priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ mod doublepq_tests {
use std::iter::FromIterator;

let v = vec![("a", 1), ("b", 2), ("f", 7)];
let mut pq: DoublePriorityQueue<_, _> = DoublePriorityQueue::from_iter(v.into_iter());
let mut pq: DoublePriorityQueue<_, _> = DoublePriorityQueue::from_iter(v);
assert_eq!(pq.pop_max(), Some(("f", 7)));
assert_eq!(pq.len(), 2);
}
Expand All @@ -256,7 +256,7 @@ mod doublepq_tests {
use std::iter::FromIterator;

let v = vec![("a", 1), ("b", 2), ("f", 7), ("g", 6), ("h", 5)];
let mut pq: DoublePriorityQueue<_, _> = DoublePriorityQueue::from_iter(v.into_iter());
let mut pq: DoublePriorityQueue<_, _> = DoublePriorityQueue::from_iter(v);

assert!(!pq.change_priority_by("z", |z| *z += 8));

Expand Down Expand Up @@ -291,7 +291,7 @@ mod doublepq_tests {
type Pq<I, P> = DoublePriorityQueue<I, P>;

let v = vec![("a", 1), ("b", 2), ("f", 7), ("g", 6), ("h", 5)];
let mut pq = Pq::from_iter(v.into_iter());
let mut pq = Pq::from_iter(v);

pq.remove(&"b").unwrap();
assert!(pq.remove(&"b").is_none());
Expand Down Expand Up @@ -545,8 +545,8 @@ mod doublepq_tests {
let val = data[idx];
simple_queue.change_priority(&(idx % window), Reverse(val));
double_queue.change_priority(&(idx % window), val);
let simple_min_result = simple_queue.peek().unwrap().1.clone().0;
let double_min_result = double_queue.peek_min().unwrap().1.clone();
let simple_min_result = (*simple_queue.peek().unwrap().1).0;
let double_min_result = *double_queue.peek_min().unwrap().1;
assert_eq!(
simple_min_result,
double_min_result,
Expand Down
6 changes: 3 additions & 3 deletions tests/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ mod pqueue_tests {
use std::iter::FromIterator;

let v = vec![("a", 1), ("b", 2), ("f", 7)];
let mut pq: PriorityQueue<_, _> = PriorityQueue::from_iter(v.into_iter());
let mut pq: PriorityQueue<_, _> = PriorityQueue::from_iter(v);
assert_eq!(pq.pop(), Some(("f", 7)));
assert_eq!(pq.len(), 2);
}
Expand All @@ -246,7 +246,7 @@ mod pqueue_tests {
use std::iter::FromIterator;

let v = vec![("a", 1), ("b", 2), ("f", 7), ("g", 6), ("h", 5)];
let mut pq: PriorityQueue<_, _> = PriorityQueue::from_iter(v.into_iter());
let mut pq: PriorityQueue<_, _> = PriorityQueue::from_iter(v);

assert!(!pq.change_priority_by("z", |z| *z += 8));
assert!(pq.change_priority_by("b", |b| *b += 8));
Expand Down Expand Up @@ -277,7 +277,7 @@ mod pqueue_tests {
type Pq<I, P> = PriorityQueue<I, P>;

let v = vec![("a", 1), ("b", 2), ("f", 7), ("g", 6), ("h", 5)];
let mut pq = Pq::from_iter(v.into_iter());
let mut pq = Pq::from_iter(v);

pq.remove(&"b").unwrap();
pq.push("b", 2);
Expand Down

0 comments on commit 2d1998b

Please sign in to comment.