Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add must use annotations #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ impl HashedIter {
/// This will create an iterator with an underlying `HashedPermutation` engine with a random
/// seed. The seed is generated using the standard library's `thread_rng` class.
#[cfg(feature = "use-rand")]
#[must_use]
pub fn new(length: NonZeroU32) -> Self {
let permutation_engine = HashedPermutation::new(length);

Expand All @@ -40,6 +41,7 @@ impl HashedIter {
}

/// Create a new hashed iterator with a given length and a seed value
#[must_use]
pub fn new_with_seed(length: NonZeroU32, seed: u32) -> Self {
let permutation_engine = HashedPermutation::new_with_seed(length, seed);

Expand Down
2 changes: 2 additions & 0 deletions src/kensler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ impl HashedPermutation {
/// This method creates a hashed permutation of some length and initializes the seed to some
/// random number created by Rust's `thread_rng`.
#[cfg(feature = "use-rand")]
#[must_use]
pub fn new(length: NonZeroU32) -> Self {
// Uses thread-rng under the hood
let seed = rand::random();
HashedPermutation { length, seed }
}

/// Create a new instance of the hashed permutation given a length and seed
#[must_use]
pub fn new_with_seed(length: NonZeroU32, seed: u32) -> Self {
HashedPermutation { seed, length }
}
Expand Down
Loading