Expand description
This crate provides a generate that constructs suitably random and reasonably unique human readable (and fairly adorable) ids, ala GiphyCat.
The name Generator implements the Iterator trait so it can be used with
adapters, consumers, and in loops.
§Usage
This crate is on crates.io and can be
used by adding adjective_adjective_animal to your dependencies in your project’s Cargo.toml
file:
[dependencies]
adjective_adjective_animal = "0.9.0"and this to your crate root:
extern crate adjective_adjective_animal;§Example: painless defaults
The easiest way to get started is to use the default Generator to return
a name:
use adjective_adjective_animal::Generator;
let mut generator = Generator::default();
println!("Your project is: {}", generator.next().unwrap());
// #=> "Your project is: IndustrialSecretiveSwan"§Example: with custom dictionaries
If you would rather supply your own custom adjective and animal word lists, you can provide your own by supplying 2 string slices. For example, this returns only one result:
use adjective_adjective_animal::Generator;
let adjectives = &["Imaginary"];
let animals = &["Bear"];
let mut generator = Generator::new(adjectives, animals);
assert_eq!("ImaginaryImaginaryBear", generator.next().unwrap());Structs§
- Generator
- A random name generator which combines an adjective, a animal, and an optional number