Enum icu_decimal::options::GroupingStrategy
source · #[non_exhaustive]pub enum GroupingStrategy {
Auto,
Never,
Always,
Min2,
}
Expand description
Configuration for how often to render grouping separators.
§Examples
use icu::decimal::options;
use icu::decimal::FixedDecimalFormatter;
use icu::locid::Locale;
use writeable::assert_writeable_eq;
let locale = Locale::UND;
let mut options: options::FixedDecimalFormatterOptions = Default::default();
options.grouping_strategy = options::GroupingStrategy::Min2;
let fdf = FixedDecimalFormatter::try_new(&locale.into(), options)
.expect("locale should be present");
let one_thousand = 1000.into();
assert_writeable_eq!(fdf.format(&one_thousand), "1000");
let ten_thousand = 10000.into();
assert_writeable_eq!(fdf.format(&ten_thousand), "10,000");
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Auto
Render grouping separators according to locale preferences.
Never
Never render grouping separators.
Always
Always render grouping separators.
For FixedDecimalFormatter
, GroupingStrategy::Always
has the same behavior as GroupingStrategy::Auto
.
Min2
Render grouping separators only if there are at least 2 digits before the final grouping separator. In most locales, this means that numbers between 1000 and 9999 do not get grouping separators, but numbers 10,000 and above will.
Trait Implementations§
source§impl Clone for GroupingStrategy
impl Clone for GroupingStrategy
source§fn clone(&self) -> GroupingStrategy
fn clone(&self) -> GroupingStrategy
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for GroupingStrategy
impl Debug for GroupingStrategy
source§impl Default for GroupingStrategy
impl Default for GroupingStrategy
source§impl From<GroupingStrategy> for FixedDecimalFormatterOptions
impl From<GroupingStrategy> for FixedDecimalFormatterOptions
source§fn from(grouping_strategy: GroupingStrategy) -> Self
fn from(grouping_strategy: GroupingStrategy) -> Self
Converts to this type from the input type.
source§impl Hash for GroupingStrategy
impl Hash for GroupingStrategy
source§impl PartialEq for GroupingStrategy
impl PartialEq for GroupingStrategy
impl Copy for GroupingStrategy
impl Eq for GroupingStrategy
impl StructuralPartialEq for GroupingStrategy
Auto Trait Implementations§
impl Freeze for GroupingStrategy
impl RefUnwindSafe for GroupingStrategy
impl Send for GroupingStrategy
impl Sync for GroupingStrategy
impl Unpin for GroupingStrategy
impl UnwindSafe for GroupingStrategy
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)