pub struct NumberArg {
pub value: Number,
/* private fields */
}Expand description
A numeric argument for keys containing {n, plural, ...} or {n, number}.
By default the number is formatted by ICU4X decimal formatter
(e.g. 1000 becomes "1,000" in en, "1 000" in fr).
Use [NumberArgument::with_display] to use a custom formatting.
ⓘ
// Auto format using the locale
t!(lang, "items", count = 1_000u32)
// Custom formatting
use rust_intl::NumberArgument;
let custom = custom_formatter(1_000_000);
t!(lang, "items", count = NumberArgument::with_display(1_000_000u64, custom))Fields§
§value: NumberRaw value.
Implementations§
Source§impl NumberArg
impl NumberArg
pub fn new(n: impl Into<Number>) -> Self
Sourcepub fn with_display(n: impl Into<Number>, display: impl Into<String>) -> Self
pub fn with_display(n: impl Into<Number>, display: impl Into<String>) -> Self
Construct with a custom formatted display string. n is still used for
plural-category resolution.
Sourcepub fn format_display(&self, locale_code: &str) -> String
pub fn format_display(&self, locale_code: &str) -> String
Format the number for display in the given locale.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NumberArg
impl RefUnwindSafe for NumberArg
impl Send for NumberArg
impl Sync for NumberArg
impl Unpin for NumberArg
impl UnsafeUnpin for NumberArg
impl UnwindSafe for NumberArg
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