pub struct DigitSet<const N: usize, const HAS_ZERO: bool> { /* private fields */ }
Expand description
An ordered set of characters that can be treated as digits.
§Const Generics
N
: The number of digits in this set.HAS_ZERO
: When true, the first digit in the set represents0
.-
For
Decimal
,HAS_ZERO
is true. This produces the ordering when counting from zero goes:n 0 1 2 … 9 10 11 12 … nominal 0 1 2 … 9 10 11 12 … -
For
LetterUpper
, ifA
were treated as a0
, the first symbol that would appear in the “tens” location would beB
:n 0 1 2 … 25 26 27 28 … nominal A B C … Z BA BB BC … This is not the expected behavior, so
LetterUpper
utilizesDigitSet::zeroless
to create a set withHAS_ZERO
set to false. This produces the order:n 0 1 2 … 25 26 27 28 … nominal A B C … Z AA AB AC … If 1-based counting is desired,
DigitSet::one_based
returns an updated set that returnsError::NoZeroSymbol
if asked to format0
. It produces this order:n 0 1 2 3 … 26 27 28 29 … nominal err A B C … Z AA AB AC …
-
Implementations§
Trait Implementations§
source§impl<const N: usize> DigitCollection for DigitSet<N, false>
impl<const N: usize> DigitCollection for DigitSet<N, false>
§type Fallback = NoFallback
type Fallback = NoFallback
The digit collection that should be used after this collection’s range
is exhausted.
source§fn has_zero_digit(&self) -> bool
fn has_zero_digit(&self) -> bool
Returns true if this collection has a symbol representing
0
at index
0.source§fn zero_based(&self) -> bool
fn zero_based(&self) -> bool
Returns true if this collection should start counting at 1 instead of 0.
This function is only called if
has_zero_digit()
returns false.source§impl<const N: usize> DigitCollection for DigitSet<N, true>
impl<const N: usize> DigitCollection for DigitSet<N, true>
§type Fallback = NoFallback
type Fallback = NoFallback
The digit collection that should be used after this collection’s range
is exhausted.
source§fn has_zero_digit(&self) -> bool
fn has_zero_digit(&self) -> bool
Returns true if this collection has a symbol representing
0
at index
0.source§fn zero_based(&self) -> bool
fn zero_based(&self) -> bool
Returns true if this collection should start counting at 1 instead of 0.
This function is only called if
has_zero_digit()
returns false.Auto Trait Implementations§
impl<const N: usize, const HAS_ZERO: bool> Freeze for DigitSet<N, HAS_ZERO>
impl<const N: usize, const HAS_ZERO: bool> RefUnwindSafe for DigitSet<N, HAS_ZERO>
impl<const N: usize, const HAS_ZERO: bool> Send for DigitSet<N, HAS_ZERO>
impl<const N: usize, const HAS_ZERO: bool> Sync for DigitSet<N, HAS_ZERO>
impl<const N: usize, const HAS_ZERO: bool> Unpin for DigitSet<N, HAS_ZERO>
impl<const N: usize, const HAS_ZERO: bool> UnwindSafe for DigitSet<N, HAS_ZERO>
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, D> NominalSystem<T> for D
impl<T, D> NominalSystem<T> for D
source§fn try_format_nominal(&self, nominal: T) -> Result<NominalString, Error<T>>
fn try_format_nominal(&self, nominal: T) -> Result<NominalString, Error<T>>
Tries to format
nominal
using this system. Read moresource§fn format_nominal(&self, nominal: T) -> NominalString
fn format_nominal(&self, nominal: T) -> NominalString
Formats
nominal
using this system.