From 927a072f9642d997f2fbe96cbaf75c4f35c1fd8e Mon Sep 17 00:00:00 2001 From: Fletcher Nichol Date: Tue, 22 Sep 2015 10:19:09 -0600 Subject: [PATCH] Add README.md. --- README.md | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 4 +-- 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b96df3d --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +# names + +[![Build Status](https://travis-ci.org/fnichol/names.svg?branch=master)](https://travis-ci.org/fnichol/names) [![license](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/fnichol/names/blob/master/LICENSE-MIT) + +Random name generator for Rust + +* Crate: https://crates.io/crates/libc +* Documentation http://fnichol.github.io/names/names/ +* Source Code: https://github.com/fnichol/names + +## Usage + +This crate is [on crates.io](https://crates.io/crates/names) and can be +used by adding `names` to your dependencies in your project's `Cargo.toml` +file: + +```toml +[dependencies] +names = "0.9.0" +``` + +and this to your crate root: + +```rust +extern crate names; +``` + +### Example: Painless defaults + +The easiest way to get started is to use the default `Generator` to return +a name: + +```rust +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: + +```rust +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()); +} +``` diff --git a/src/lib.rs b/src/lib.rs index e1a0ce9..84e9fbe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,7 +31,7 @@ //! //! let mut generator = Generator::default(Name::Plain); //! println!("Your project is: {}", generator.next().unwrap()); -//! // #=> "rusty-nail" +//! // #=> "Your project is: rusty-nail" //! ``` //! //! If more randomness is required, you can generate a name with a trailing @@ -42,7 +42,7 @@ //! //! let mut generator = Generator::default(Name::Numbered); //! println!("Your project is: {}", generator.next().unwrap()); -//! // #=> "pushy-pencil-5602" +//! // #=> "Your project is: pushy-pencil-5602" //! ``` //! //! # Example: with custom dictionaries