Skip to content
Merged
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "Apache-2.0"
name = "petname"
readme = "README.md"
repository = "https://github.com/allenap/rust-petname"
version = "3.0.0-alpha.1"
version = "3.0.0-alpha.2"

[lib]
name = "petname"
Expand All @@ -26,7 +26,7 @@ required-features = ["clap", "default-rng", "default-words"]
# _every time_ you want to build the binary, so it's here as a convenience.
default = ["clap", "default-rng", "default-words"]
# Allows generating petnames with thread rng.
default-rng = ["rand/std", "rand/std_rng"]
default-rng = ["rand/thread_rng"]
# Allows the default word lists to be used.
default-words = []

Expand All @@ -42,7 +42,7 @@ quote = "1"
[dependencies]
clap = { version = "4.4", features = ["cargo", "derive"], optional = true }
itertools = { version = ">=0.11", default-features = false }
rand = { version = "0.8", default-features = false }
rand = { version = "0.9", default-features = false }

[package.metadata.docs.rs]
# Limit docs.rs builds to a single tier one target, because they're identical on
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ use alloc::{
vec::Vec,
};

use rand::seq::{IteratorRandom, SliceRandom};
use rand::seq::{IndexedRandom, IteratorRandom};

/// Convenience function to generate a new petname from default word lists.
#[allow(dead_code)]
Expand Down Expand Up @@ -153,7 +153,7 @@ pub trait Generator<'a> {
/// when you want to use a custom source of randomness.
#[cfg(feature = "default-rng")]
fn generate_one(&self, words: u8, separator: &str) -> Option<String> {
self.generate(&mut rand::thread_rng(), words, separator)
self.generate(&mut rand::rng(), words, separator)
}

/// Generate a new petname and return the constituent words.
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ where

// We're going to need a source of randomness.
let mut rng =
cli.seed.map(rand::rngs::StdRng::seed_from_u64).unwrap_or_else(rand::rngs::StdRng::from_entropy);
cli.seed.map(rand::rngs::StdRng::seed_from_u64).unwrap_or_else(rand::rngs::StdRng::from_os_rng);

// Stream, or print a limited number of words?
let count = if cli.stream { None } else { Some(cli.count) };
Expand Down Expand Up @@ -311,6 +311,6 @@ mod integration {
#[test]
fn option_seed() {
let cli = super::Cli::parse_from(["petname", "--seed=12345", "--words=3"]);
assert_eq!(run_and_capture(cli), "meaningfully-enthralled-pinscher\n");
assert_eq!(run_and_capture(cli), "meaningfully-enthralled-vendace\n");
}
}
2 changes: 1 addition & 1 deletion tests/alliterations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn alliterations_generate_uses_adverb_adjective_name() {
let petnames = Petnames::new("able bold", "burly curly", "ant bee cow");
let alliterations: Alliterations = petnames.into();
assert_eq!(
alliterations.generate(&mut StepRng::new(1234567890, 1), 3, "-"),
alliterations.generate(&mut StepRng::new(6234567891, 1), 3, "-"),
Some("burly-bold-bee".into())
);
}
Expand Down