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
impl FractionalPrinter
Sourcefn from_span(
span: &Span,
unit: FractionalUnit,
fmtint: DecimalFormatter,
fmtfraction: FractionalFormatter,
) -> FractionalPrinter
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.
Sourcefn from_duration(
dur: &SignedDuration,
unit: FractionalUnit,
fmtint: DecimalFormatter,
fmtfraction: FractionalFormatter,
) -> FractionalPrinter
fn from_duration( dur: &SignedDuration, unit: FractionalUnit, fmtint: DecimalFormatter, fmtfraction: FractionalFormatter, ) -> FractionalPrinter
Like from_span
, but for SignedDuration
.
Sourcefn is_plural(&self) -> bool
fn is_plural(&self) -> bool
Returns true if this integer/fraction should be considered plural when choosing what designator to use.
Sourcefn must_write_digits(&self) -> bool
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.