Struct plurr::Plurr[][src]

pub struct Plurr<'a> { /* fields omitted */ }

Implementations

impl<'a> Plurr<'a>[src]

pub fn new() -> Self[src]

pub fn locale(&mut self, locale_code: &'a str) -> &mut Self[src]

Sets the locale for Plurr. If this is not called or an incompatible locale_code is provided, it defaults to English.

pub fn auto_plurals(&mut self, auto_plurals: bool) -> &mut Self[src]

Toggles the auto-plural behavior.

  • With auto-plurals, Plurr will automatically select the plural form for the current locale.
  • Without auto-plurals, you will need to manually provide an N_PLURAL parameter before calling format().

pub fn strict(&mut self, strict: bool) -> &mut Self[src]

Toggles strict mode. In strict mode, errors are not skipped.

pub fn param<T: ToString>(&mut self, key: &str, value: T) -> &mut Self[src]

Stores a parameter value. Parameters must be fed before calling format().

pub fn format(&mut self, value: &str) -> Result<String, PlurrError>[src]

Formats a Plurr string and returns the evaluated string.

For the format spec please check out the project README.

Examples

use plurr::Plurr;

let mut p = Plurr::new();
let s = "Delete {N_PLURAL:{N} file|{N} files}?";

assert_eq!(
    p.param("N", "5").format(s),
    Ok("Delete 5 files?".to_string())
);

Trait Implementations

impl<'a> Debug for Plurr<'a>[src]

impl<'a> Default for Plurr<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Plurr<'a>[src]

impl<'a> Send for Plurr<'a>[src]

impl<'a> Sync for Plurr<'a>[src]

impl<'a> Unpin for Plurr<'a>[src]

impl<'a> UnwindSafe for Plurr<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.