Suitably random and reasonably unique human readable (and fairly adorable) ids, ala GiphyCat
Go to file
Fletcher Nichol d9e89ad782 [cli] Use clap_app! macro and update version of clap.
Signed-off-by: Fletcher Nichol <fnichol@nichol.ca>
2016-04-29 19:39:55 -06:00
cli [cli] Use clap_app! macro and update version of clap. 2016-04-29 19:39:55 -06:00
data Inline the word data with a build script. 2016-04-29 19:07:14 -06:00
src Inline the word data with a build script. 2016-04-29 19:07:14 -06:00
.gitignore Extract cli into a subproject. 2015-09-22 09:15:03 -06:00
.travis.yml Redirect GitHub pages to names/index.html. 2015-09-22 10:00:34 -06:00
build.rs Inline the word data with a build script. 2016-04-29 19:07:14 -06:00
Cargo.toml Inline the word data with a build script. 2016-04-29 19:07:14 -06:00
CHANGELOG.md Process CHANGELOG. 2015-11-01 19:15:28 -07:00
LICENSE-MIT Add MIT license. 2015-09-22 10:08:34 -06:00
README.md Add a crates.io badge to README. 2015-11-01 19:12:52 -07:00

names

Build Status license

Random name generator for Rust

Usage

This crate is on crates.io and can be used by adding names to your dependencies in your project's Cargo.toml file:

[dependencies]
names = "0.10.0"

and this to your crate root:

extern crate names;

Example: Painless defaults

The easiest way to get started is to use the default Generator to return a name:

use names::{Generator, Name};

fn main() {
    let mut generator = Generator::default(Name::Plain);

    println!("Your project is: {}", generator.next().unwrap());
    // #=> "Your project is: rusty-nail"
}

If more randomness is required, you can generate a name with a trailing 4-digit number:

use names::{Generator, Name};

fn main() {
    let mut generator = Generator::default(Name::Numbered);
    println!("Your project is: {}", generator.next().unwrap());
    // #=> "Your project is: pushy-pencil-5602"
}

Example: with custom dictionaries

If you would rather supply your own custom adjective and noun word lists, you can provide your own by supplying 2 string slices. For example, this returns only one result:

use names::{Generator, Name};

fn main() {
    let adjectives = &["imaginary"];
    let nouns = &["roll"];
    let mut generator = Generator::new(adjectives, nouns, Name::Plain);

    assert_eq!("imaginary-roll", generator.next().unwrap());
}