pub struct RNG {
pub name: String,
pub prefixes: Syllables,
pub centers: Syllables,
pub suffixes: Syllables,
pub bad_syllables: Vec<String>,
}
Expand description
RNG (Random Name Generator) is a library that generates random names based upon one of the available Languages.
Usage:
use rnglib::{RNG, Language};
let rng = RNG::try_from(&Language::Elven).unwrap();
let first_name = rng.generate_name();
let last_name = rng.generate_name();
println!("{}: {} {}", rng.name, first_name, last_name)
Fields§
§name: String
§prefixes: Syllables
§centers: Syllables
§suffixes: Syllables
§bad_syllables: Vec<String>
Implementations§
source§impl RNG
impl RNG
sourcepub fn new(language: &Language) -> Result<RNG, RNG>
pub fn new(language: &Language) -> Result<RNG, RNG>
Use if you want to return the RNG entity, even if there are issues with some
of the syllables. Otherwise, use RNG::from
.
Errors
Errors out if the language file is not able to be processed correctly.
sourcepub fn new_from_file(filename: String) -> Result<RNG, RNGError>
pub fn new_from_file(filename: String) -> Result<RNG, RNGError>
Errors
Errors out if the language file is not able to be processed correctly.
pub fn random() -> RNG
pub fn empty(name: String) -> RNG
pub fn is_empty(&self) -> bool
pub fn is_valid(&self) -> bool
pub fn generate_name(&self) -> String
sourcepub fn generate_names(&self, number: usize, is_short: bool) -> Vec<String>
pub fn generate_names(&self, number: usize, is_short: bool) -> Vec<String>
Returns a vector of names based on the number passed in. Returns
short weighted names if is_short
is set to true.
pub fn generate_names_string(&self, n: usize, is_short: bool) -> String
pub fn generate_short(&self) -> String
pub fn generate_name_by_count(&self, count: u8) -> String
pub fn generate_syllables(&self) -> Syllables
sourcepub fn generate_syllables_by_count(&self, syllable_count: u8) -> Syllables
pub fn generate_syllables_by_count(&self, syllable_count: u8) -> Syllables
Panics
Errors out if the language file is not able to be processed correctly.
pub fn syllables(&self) -> Syllables
Trait Implementations§
impl StructuralPartialEq for RNG
Auto Trait Implementations§
impl RefUnwindSafe for RNG
impl Send for RNG
impl Sync for RNG
impl Unpin for RNG
impl UnwindSafe for RNG
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more