Skip to content

Commit 776c84f

Browse files
committed
clippy --fix
1 parent 923f0fe commit 776c84f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#![forbid(unsafe_code)]
6161
#![deny(missing_docs)]
6262
#![deny(missing_debug_implementations)]
63+
#![warn(clippy::pedantic)]
6364

6465
use std::borrow::Borrow;
6566
use std::cmp;
@@ -174,6 +175,7 @@ pub struct Book<K> {
174175

175176
impl<K: Ord + Clone> Book<K> {
176177
/// Returns the underlying B-Tree.
178+
#[must_use]
177179
pub fn into_inner(self) -> BTreeMap<K, BitVec> {
178180
self.book
179181
}
@@ -189,11 +191,13 @@ impl<K: Ord + Clone> Book<K> {
189191
}
190192

191193
/// Returns the number of symbols in the book.
194+
#[must_use]
192195
pub fn len(&self) -> usize {
193196
self.book.len()
194197
}
195198

196199
/// Returns true if the map has no symbols.
200+
#[must_use]
197201
pub fn is_empty(&self) -> bool {
198202
self.book.is_empty()
199203
}
@@ -296,6 +300,7 @@ pub struct CodeBuilder<K: Ord + Clone, W: Saturating + Ord> {
296300

297301
impl<K: Ord + Clone, W: Saturating + Ord> CodeBuilder<K, W> {
298302
/// Creates a new, empty `CodeBuilder<K, W>`.
303+
#[must_use]
299304
pub fn new() -> CodeBuilder<K, W> {
300305
CodeBuilder {
301306
heap: BinaryHeap::new(),
@@ -305,6 +310,7 @@ impl<K: Ord + Clone, W: Saturating + Ord> CodeBuilder<K, W> {
305310

306311
/// Creates a new, empty `CodeBuilder<K, W>` and preallocates space
307312
/// for `capacity` symbols.
313+
#[must_use]
308314
pub fn with_capacity(capacity: usize) -> CodeBuilder<K, W> {
309315
CodeBuilder {
310316
heap: BinaryHeap::with_capacity(capacity),
@@ -328,6 +334,7 @@ impl<K: Ord + Clone, W: Saturating + Ord> CodeBuilder<K, W> {
328334

329335
/// Constructs a [book](struct.Book.html) and [tree](struct.Tree.html) pair
330336
/// for encoding and decoding.
337+
#[must_use]
331338
pub fn finish(mut self) -> (Book<K>, Tree<K>) {
332339
let mut book = Book::new();
333340

@@ -494,7 +501,7 @@ mod tests {
494501
#[test]
495502
fn test_uniform_from_static() {
496503
const WEIGHTS: &[(&char, &usize)] = &[(&'a', &1), (&'b', &1), (&'c', &1), (&'d', &1)];
497-
let (book, tree) = codebook(WEIGHTS.iter().cloned());
504+
let (book, tree) = codebook(WEIGHTS.iter().copied());
498505

499506
let mut buffer = BitVec::new();
500507
book.encode(&mut buffer, &'a').unwrap();
@@ -546,7 +553,7 @@ mod tests {
546553
let (book, _) = builder.finish();
547554

548555
let len = |symbol| {
549-
book.get(symbol).map_or(0, |code| code.len())
556+
book.get(symbol).map_or(0, bit_vec::BitVec::len)
550557
};
551558

552559
at >= ct || len("CT") <= len("AT") ||

0 commit comments

Comments
 (0)