pub struct Locale {
pub decimal_point: char,
pub thousands_sep: Option<char>,
pub grouping: [u8; 4],
pub group_repeat: bool,
}
Expand description
The numeric locale. Note this is a pure value type.
Fields§
§decimal_point: char
The decimal point. Only single-char decimal points are supported.
thousands_sep: Option<char>
The thousands separator, or None if none. Note some obscure locales like it_IT.ISO8859-15 seem to have a multi-char thousands separator! We do not support that.
grouping: [u8; 4]
The grouping of digits. This is to be read from left to right. For example, the number 88888888888888 with a grouping of [2, 3, 4, 4] would produce the string “8,8888,8888,888,88”. If 0, no grouping at all.
group_repeat: bool
If true, the group is repeated. If false, there are no groups after the last.
Implementations§
Source§impl Locale
impl Locale
Sourcepub fn apply_grouping(&self, input: &str) -> String
pub fn apply_grouping(&self, input: &str) -> String
Given a string containing only ASCII digits, return a new string with thousands separators applied. This panics if the locale has no thousands separator; callers should only call this if there is a thousands separator.