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