jiff::fmt::friendly::printer

Struct FractionalPrinter

Source
struct FractionalPrinter {
    integer: i64,
    fraction: i64,
    fmtint: DecimalFormatter,
    fmtfraction: FractionalFormatter,
}
Expand description

A printer for a fraction with an integer and fraction component.

This also includes the formatter for the integer component and the formatter for the fractional component.

Fields§

§integer: i64§fraction: i64§fmtint: DecimalFormatter§fmtfraction: FractionalFormatter

Implementations§

Source§

impl FractionalPrinter

Source

fn from_span( span: &Span, unit: FractionalUnit, fmtint: DecimalFormatter, fmtfraction: FractionalFormatter, ) -> FractionalPrinter

Build a fractional printer for the Span given. This includes the ..

Callers must ensure that all units greater than FractionalUnit are zero in the span given.

Note that the printer returned only prints a fractional component if necessary. For example, if the fractional component is zero and precision is None, or if precision is Some(0), then no fractional component will be emitted.

Source

fn from_duration( dur: &SignedDuration, unit: FractionalUnit, fmtint: DecimalFormatter, fmtfraction: FractionalFormatter, ) -> FractionalPrinter

Like from_span, but for SignedDuration.

Source

fn is_zero(&self) -> bool

Returns true if both the integer and fractional component are zero.

Source

fn is_plural(&self) -> bool

Returns true if this integer/fraction should be considered plural when choosing what designator to use.

Source

fn must_write_digits(&self) -> bool

Returns true if and only if this printer must write some kind of number when print is called.

The only case where this returns false is when both the integer and fractional component are zero and the precision is fixed to a number greater than zero.

Source

fn print<W: Write>(&self, wtr: W) -> Result<(), Error>

Prints the integer and optional fractional component.

This will always print the integer, even if it’s zero. Therefore, if the caller wants to omit printing zero, the caller should do their own conditional logic.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.