Suitably random and reasonably unique human readable (and fairly adorable) ids, ala GiphyCat
Go to file
Travis Burtrum ea80cdd34a
moparisthebest/adjective-adjective-animal/pipeline/head This commit looks good Details
Abandon travis-ci for jenkins
2020-11-26 18:43:31 -05:00
.ci Abandon travis-ci for jenkins 2020-11-26 18:43:31 -05:00
cli Update to adjective_adjective_animal 2018-08-07 00:08:48 -04:00
data Update to adjective_adjective_animal 2018-08-07 00:08:48 -04:00
src Update to adjective_adjective_animal 2018-08-07 00:08:48 -04:00
.gitignore Update to adjective_adjective_animal 2018-08-07 00:08:48 -04:00
CHANGELOG.md Update to adjective_adjective_animal 2018-08-07 00:08:48 -04:00
Cargo.toml Update to adjective_adjective_animal 2018-08-07 00:08:48 -04:00
LICENSE-MIT Update to adjective_adjective_animal 2018-08-07 00:08:48 -04:00
README.md Abandon travis-ci for jenkins 2020-11-26 18:43:31 -05:00
build.rs Remove stray semicolon (#1) 2019-10-13 12:25:30 -04:00

README.md

adjective_adjective_animal

Build Status license

Rust library to generate suitably random and reasonably unique human readable (and fairly adorable) ids, ala GiphyCat

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.1.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;

fn main() {
    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;

fn main() {
    let adjectives = &["Imaginary"];
    let animals = &["Bear"];
    let mut generator = Generator::new(adjectives, animals);

    assert_eq!("ImaginaryImaginaryBear", generator.next().unwrap());
}

Credits

  • rust's names crate, which this is forked from
  • npm's adjective-adjective-animal for lists
    • curl 'https://raw.githubusercontent.com/a-type/adjective-adjective-animal/master/lib/lists/animals.js' | grep -Eo '"[^"]+"' | tr -d '"' | tr '[:upper:]' '[:lower:]' | sed 's/.*/\u&/' | sort | uniq > animals.txt
    • curl 'https://raw.githubusercontent.com/a-type/adjective-adjective-animal/master/lib/lists/adjectives.js' | grep -Eo '"[^"]+"' | tr -d '"' | tr '[:upper:]' '[:lower:]' | sed 's/.*/\u&/' | sort | uniq > adjectives.txt