Struct names::Generator[][src]

pub struct Generator<'a> { /* fields omitted */ }

A random name generator which combines an adjective, a noun, and an optional number

A Generator takes a slice of adjective and noun words strings and has a naming strategy (with or without a number appended).

Implementations

impl<'a> Generator<'a>[src]

pub fn new(
    adjectives: &'a [&'a str],
    nouns: &'a [&'a str],
    naming: Name
) -> Self
[src]

Constructs a new Generator<'a>

Examples

use names::{Generator, Name};

let adjectives = &["sassy"];
let nouns = &["clocks"];
let naming = Name::Plain;

let mut generator = Generator::new(adjectives, nouns, naming);

assert_eq!("sassy-clocks", generator.next().unwrap());

pub fn with_naming(naming: Name) -> Self[src]

Construct and returns a default Generator<'a> containing a large collection of adjectives and nouns

use names::{Generator, Name};

let mut generator = Generator::with_naming(Name::Plain);

println!("My new name is: {}", generator.next().unwrap());

Trait Implementations

impl<'a> Default for Generator<'a>[src]

impl<'a> Iterator for Generator<'a>[src]

type Item = String

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Generator<'a>

impl<'a> Send for Generator<'a>

impl<'a> Sync for Generator<'a>

impl<'a> Unpin for Generator<'a>

impl<'a> UnwindSafe for Generator<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.