pub enum NumberFormat {
Arabic,
Letters,
CapitalLetters,
Roman,
CapitalRoman,
Symbols,
Superscript,
Subscript,
}Expand description
A number format: one way of writing a number as characters, as decimal digits, letters, roman numerals, footnote symbols, or superscript or subscript digits.
A number template refers to a format by the name that
written_name returns: #{arabic} writes the
number in Arabic. The settings use the same
names, so these names are part of the settings format and stay fixed.
Every format except Arabic writes the empty text for a number it cannot
write: zero, a negative number, and a number so large that its text would
be longer than MAX_CHARS characters. Arabic
writes the decimal digits of any number, including 0 and a leading minus
sign.
§Examples
use flm_core::stdlib::features::numbering::NumberFormat;
assert_eq!(NumberFormat::Arabic.text(12), "12");
assert_eq!(NumberFormat::Letters.text(27), "aa");
assert_eq!(NumberFormat::CapitalRoman.text(2099), "MMXCIX");
assert_eq!(NumberFormat::Roman.text(0), "");
assert_eq!(NumberFormat::from_written_name("fnsymbol"), Some(NumberFormat::Symbols));Variants§
Arabic
The decimal digits: 1, 2, 12. Written arabic.
Letters
Lowercase letters, repeated instead of counted in base twenty-six:
a, …, z, aa, bb, …, zz, aaa. Written alph.
CapitalLetters
Letters in uppercase: A, …, AA. Written
Alph.
Roman
Lowercase roman numerals: i, iv, mmxcix. Written roman.
CapitalRoman
Roman in uppercase: I, IV, MMXCIX.
Written Roman.
Symbols
The footnote symbols *, †, ‡, §, ¶, ‖, doubled from the
seventh, tripled from the thirteenth. Written fnsymbol.
Superscript
The decimal digits as superscript characters: ¹⁷. Written
unicodesuperscript.
Subscript
The decimal digits as subscript characters: ₁₇. Written
unicodesubscript.
Implementations§
Source§impl NumberFormat
impl NumberFormat
Sourcepub const ALL: [NumberFormat; 8]
pub const ALL: [NumberFormat; 8]
Every format, in the order of the variants above.
Sourcepub const MAX_CHARS: usize = 1024
pub const MAX_CHARS: usize = 1024
The length, in characters, of the longest text a format other than
Arabic writes. A number whose text would be
longer gets the empty text, so that the work of writing a number is
bounded for every number.
Sourcepub fn written_name(self) -> &'static str
pub fn written_name(self) -> &'static str
Returns the name by which a number template and the settings refer to
this format: arabic, alph, Alph, roman, Roman, fnsymbol,
unicodesuperscript or unicodesubscript.
Sourcepub fn from_written_name(name: &str) -> Option<NumberFormat>
pub fn from_written_name(name: &str) -> Option<NumberFormat>
Returns the format whose written name is name, or None when no
format has that name. The inverse of
written_name.
Trait Implementations§
Source§impl Clone for NumberFormat
impl Clone for NumberFormat
impl Copy for NumberFormat
Source§impl Debug for NumberFormat
impl Debug for NumberFormat
Source§impl Display for NumberFormat
impl Display for NumberFormat
impl Eq for NumberFormat
Source§impl Hash for NumberFormat
impl Hash for NumberFormat
Source§impl Ord for NumberFormat
impl Ord for NumberFormat
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for NumberFormat
impl PartialEq for NumberFormat
Source§impl PartialOrd for NumberFormat
impl PartialOrd for NumberFormat
impl StructuralPartialEq for NumberFormat
Auto Trait Implementations§
impl Forget for NumberFormat
impl Freeze for NumberFormat
impl Move for NumberFormat
impl RefUnwindSafe for NumberFormat
impl Send for NumberFormat
impl Sync for NumberFormat
impl Unpin for NumberFormat
impl UnsafeUnpin for NumberFormat
impl UnwindSafe for NumberFormat
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more