pub struct NameBuilder { /* private fields */ }
Expand description
Builder type to construct a Name
.
Implementations§
Source§impl NameBuilder
impl NameBuilder
Sourcepub fn new(id: Arc<AtomicUsize>) -> Self
pub fn new(id: Arc<AtomicUsize>) -> Self
Create a new NameBuilder
instance.
The passed id
is used to generate unique ids for unnamed types.
Sourcepub fn with_id(self, value: bool) -> Self
pub fn with_id(self, value: bool) -> Self
Wether to add a unique id to the generated name or not.
Sourcepub fn generate_id(self) -> Self
pub fn generate_id(self) -> Self
Generate the id for the name.
This can be useful if you want to clone the builder to generate multiple names with the same id. For example for a field name and corresponding field type.
Sourcepub fn unique_name<T>(self, value: T) -> Selfwhere
T: Display,
pub fn unique_name<T>(self, value: T) -> Selfwhere
T: Display,
Set a unique name.
This will automatically set with_id
to false
.
Set a shared name.
This will automatically set with_id
to true
.
Sourcepub fn or<T>(self, fallback: T) -> Selfwhere
T: NameFallback,
pub fn or<T>(self, fallback: T) -> Selfwhere
T: NameFallback,
Uses the name that is already stored in the builder, or the passed
fallback
value if the name was not set yet.
Sourcepub fn or_else<F, T>(self, fallback: F) -> Selfwhere
F: FnOnce() -> T,
T: NameFallback,
pub fn or_else<F, T>(self, fallback: F) -> Selfwhere
F: FnOnce() -> T,
T: NameFallback,
Uses the name that is already stored in the builder, or the value that
is returned by the passed fallback
closure if the name was not set yet.
Sourcepub fn extend<I>(self, replace: bool, iter: I) -> Self
pub fn extend<I>(self, replace: bool, iter: I) -> Self
Add a extension to the name.
Extensions are added as to the generated name as prefix.
Sourcepub fn remove_suffix(self, suffix: &str) -> Self
pub fn remove_suffix(self, suffix: &str) -> Self
Remove the specified suffix
from the name and the extension.
Sourcepub fn has_extension(&self) -> bool
pub fn has_extension(&self) -> bool
Returns true
if a extension was specified, false
otherwise.
Trait Implementations§
Source§impl Clone for NameBuilder
impl Clone for NameBuilder
Source§fn clone(&self) -> NameBuilder
fn clone(&self) -> NameBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more