pub enum Term<'a> {
Simple {
singular: &'a str,
},
Explicit {
singular: &'a str,
plural: &'a str,
},
}Expand description
A struct which formats the given value in either singular (1) or plural (2+).
§Examples
assert_eq!(Term::simple("word").with(1).to_string(), "word");
assert_eq!(Term::simple("word").with(2).to_string(), "words");
assert_eq!(Term::new("index", "indices").with(1).to_string(), "index");
assert_eq!(Term::new("index", "indices").with(2).to_string(), "indices");Variants§
Simple
Construct the plural term by appending an s.
Explicit
Explicitly use the give singular and plural term.
Implementations§
Source§impl<'a> Term<'a>
impl<'a> Term<'a>
Sourcepub const fn simple(singular: &'a str) -> Self
pub const fn simple(singular: &'a str) -> Self
Creates a new simple term whose plural term is created by appending an
s.
Sourcepub const fn new(singular: &'a str, plural: &'a str) -> Self
pub const fn new(singular: &'a str, plural: &'a str) -> Self
Creates a term from the explicit singular and plural form.
Sourcepub fn with(self, plural: impl Plural) -> impl Display + 'a
pub fn with(self, plural: impl Plural) -> impl Display + 'a
Formats this term with the given value.
§Examples
assert_eq!(Term::simple("word").with(1).to_string(), "word");
assert_eq!(Term::simple("word").with(2).to_string(), "words");
assert_eq!(Term::new("index", "indices").with(1).to_string(), "index");
assert_eq!(Term::new("index", "indices").with(2).to_string(), "indices");Trait Implementations§
impl<'a> Copy for Term<'a>
impl<'a> Eq for Term<'a>
impl<'a> StructuralPartialEq for Term<'a>
Auto Trait Implementations§
impl<'a> Freeze for Term<'a>
impl<'a> RefUnwindSafe for Term<'a>
impl<'a> Send for Term<'a>
impl<'a> Sync for Term<'a>
impl<'a> Unpin for Term<'a>
impl<'a> UnwindSafe for Term<'a>
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more