pub struct NamePool {
pub first_names_male: Vec<String>,
pub first_names_female: Vec<String>,
pub last_names: Vec<String>,
pub culture: NameCulture,
}Expand description
Pool of names for a specific culture.
Fields§
§first_names_male: Vec<String>Male first names
first_names_female: Vec<String>Female first names
last_names: Vec<String>Last names / family names
culture: NameCultureThe culture this pool represents
Implementations§
Source§impl NamePool
impl NamePool
Sourcepub fn western_us() -> Self
pub fn western_us() -> Self
Create a Western US name pool.
Sourcepub fn for_culture(culture: NameCulture) -> Self
pub fn for_culture(culture: NameCulture) -> Self
Get a name pool for a specific culture.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate that the name pool has at least one entry in each list.
Returns Err if any name list is empty, preventing panics during generation.
Sourcepub fn generate_name(&self, rng: &mut impl Rng) -> PersonName
pub fn generate_name(&self, rng: &mut impl Rng) -> PersonName
Generate a random name from this pool.
Sourcepub fn from_culture_config(config: &CultureConfig, culture: NameCulture) -> Self
pub fn from_culture_config(config: &CultureConfig, culture: NameCulture) -> Self
Create a NamePool from a CultureConfig loaded from a country pack.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NamePool
impl RefUnwindSafe for NamePool
impl Send for NamePool
impl Sync for NamePool
impl Unpin for NamePool
impl UnsafeUnpin for NamePool
impl UnwindSafe for NamePool
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.