#[non_exhaustive]pub enum SubsecondDigits {
S1 = 1,
S2 = 2,
S3 = 3,
S4 = 4,
S5 = 5,
S6 = 6,
S7 = 7,
S8 = 8,
S9 = 9,
}
Expand description
A specification for how many fractional second digits to display.
For example, to display the time with millisecond precision, use
SubsecondDigits::S3
.
Lower-precision digits will be truncated.
§Examples
Times can be displayed with a custom number of fractional digits from 0-9:
use icu::calendar::Gregorian;
use icu::datetime::fieldsets::T;
use icu::datetime::input::Time;
use icu::datetime::options::SubsecondDigits;
use icu::datetime::options::TimePrecision;
use icu::datetime::FixedCalendarDateTimeFormatter;
use icu::locale::locale;
use writeable::assert_writeable_eq;
let formatter = FixedCalendarDateTimeFormatter::<(), _>::try_new(
locale!("en-US").into(),
T::short()
.with_time_precision(TimePrecision::Subsecond(SubsecondDigits::S2)),
)
.unwrap();
assert_writeable_eq!(
formatter.format(&Time::try_new(16, 12, 20, 543200000).unwrap()),
"4:12:20.54 PM"
);
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.
S1 = 1
One fractional digit (tenths of a second).
S2 = 2
Two fractional digits (hundredths of a second).
S3 = 3
Three fractional digits (milliseconds).
S4 = 4
Four fractional digits.
S5 = 5
Five fractional digits.
S6 = 6
Six fractional digits (microseconds).
S7 = 7
Seven fractional digits.
S8 = 8
Eight fractional digits.
S9 = 9
Nine fractional digits (nanoseconds)
Trait Implementations§
Source§impl Clone for SubsecondDigits
impl Clone for SubsecondDigits
Source§fn clone(&self) -> SubsecondDigits
fn clone(&self) -> SubsecondDigits
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 SubsecondDigits
impl Debug for SubsecondDigits
Source§impl From<SubsecondDigits> for u8
impl From<SubsecondDigits> for u8
Source§fn from(value: SubsecondDigits) -> u8
fn from(value: SubsecondDigits) -> u8
Converts to this type from the input type.
Source§impl Hash for SubsecondDigits
impl Hash for SubsecondDigits
Source§impl PartialEq for SubsecondDigits
impl PartialEq for SubsecondDigits
Source§impl TryFrom<u8> for SubsecondDigits
impl TryFrom<u8> for SubsecondDigits
impl Copy for SubsecondDigits
impl Eq for SubsecondDigits
impl StructuralPartialEq for SubsecondDigits
Auto Trait Implementations§
impl Freeze for SubsecondDigits
impl RefUnwindSafe for SubsecondDigits
impl Send for SubsecondDigits
impl Sync for SubsecondDigits
impl Unpin for SubsecondDigits
impl UnwindSafe for SubsecondDigits
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§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>
Converts
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>
Converts
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