Enum FractionalUnit
#[non_exhaustive]
pub enum FractionalUnit
Configuration for SpanPrinter::fractional.
This controls what kind of fractional unit to use when printing a duration.
The default, unless SpanPrinter::hours_minutes_seconds is enabled, is
to not write any fractional numbers at all.
The fractional unit set refers to the smallest whole integer that can occur in a "friendly" formatted duration. If there are any non-zero units less than the fractional unit in the duration, then they are formatted as a fraction.
Example
This example shows how to write the same duration with different fractional settings:
use ;
let duration = from_secs;
let printer = new
.fractional;
assert_eq!;
let printer = new
.fractional;
assert_eq!;
let printer = new
.fractional;
assert_eq!;
Variants
-
Hour The smallest whole integer unit allowed is hours.
WARNING: Since fractional units are limited to 9 decimal places, using this setting could result in precision loss.
-
Minute The smallest whole integer unit allowed is minutes.
WARNING: Since fractional units are limited to 9 decimal places, using this setting could result in precision loss.
-
Second The smallest whole integer unit allowed is seconds.
-
Millisecond The smallest whole integer unit allowed is milliseconds.
-
Microsecond The smallest whole integer unit allowed is microseconds.
Trait Implementations
impl Clone for FractionalUnit
fn clone(&self) -> FractionalUnit
impl Copy for FractionalUnit
impl Debug for FractionalUnit
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl Freeze for FractionalUnit
impl RefUnwindSafe for FractionalUnit
impl Send for FractionalUnit
impl Sync for FractionalUnit
impl Unpin for FractionalUnit
impl UnsafeUnpin for FractionalUnit
impl UnwindSafe for FractionalUnit
Blanket Implementations
impl<T> Any for FractionalUnit
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for FractionalUnit
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for FractionalUnit
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for FractionalUnit
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for FractionalUnit
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for FractionalUnit
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for FractionalUnit
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for FractionalUnit
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for FractionalUnit
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>