#korean #random #generator #string #name #generate #user-name

yanked random-nickname

The Korean random nickname generator implemented in Rust

1 unstable release

0.1.0 Jun 20, 2023

#26 in #korean

MIT license

10KB
67 lines

The random nickname generator provides a generate that constructs random name strings for use anonumous username, etc.

Generator implements the Iterator trait so it can be used with adaptors, consumers, and in loops.

Usage

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

[dependencies]
random-nickname = "0.14.0"

Examples

Example: with naming or noun type

The easiest way to get started is to use Generator::with_naming() to return a full nickname:

use random-nickname::Generator;

let mut animal_name_generator = Generator::with_naming(NounType::Animal);
let mut character_name_generator = Generator::with_characters(Naming::NounOnly);
println!("You can choose a nickname between \"{}\" and \"{}\"",
    animal_name_generator.next().unwrap(),
    character_name_generator.next().unwrap());
// #=> "You can choose a nickname between "잠자는 숲속의 삵" and "레고를 밟은 하이템플러"

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 random-nickname::{Generator, Naming};

let adjectives = &["멋있는"];
let nouns = &["정총무"];
let mut generator = Generator::new(adjectives, nouns, Naming::default());

assert_eq!("멋있는 정총무", generator.next().unwrap());

Dependencies

~310KB