pub struct FloatFormatOptions {
pub always_sign: bool,
pub precision: usize,
pub num_decimals: Option<usize>,
pub strip_trailing_zeros: bool,
pub min_decimals_for_thousands_separators: usize,
}Expand description
Options for how to format a floating point number, e.g. an f64.
Fields§
§always_sign: boolAlways show the sign, even if it is positive (+).
precision: usizeMaximum digits of precision to use.
This includes both the integer part and the fractional part.
num_decimals: Option<usize>Max number of decimals to show after the decimal point.
If not specified, Self::precision is used instead.
strip_trailing_zeros: bool§min_decimals_for_thousands_separators: usizeOnly add thousands separators to decimals if there are at least this many decimals.
Implementations§
Source§impl FloatFormatOptions
impl FloatFormatOptions
Sourcepub const DEFAULT_f16: Self
pub const DEFAULT_f16: Self
Default options for formatting an half::f16.
Sourcepub const DEFAULT_f32: Self
pub const DEFAULT_f32: Self
Default options for formatting an f32.
Sourcepub const DEFAULT_f64: Self
pub const DEFAULT_f64: Self
Default options for formatting an f64.
Sourcepub fn with_always_sign(self, always_sign: bool) -> Self
pub fn with_always_sign(self, always_sign: bool) -> Self
Always show the sign, even if it is positive (+).
Sourcepub fn with_precision(self, precision: usize) -> Self
pub fn with_precision(self, precision: usize) -> Self
Show at most this many digits of precision, including both the integer part and the fractional part.
Sourcepub fn with_decimals(self, num_decimals: usize) -> Self
pub fn with_decimals(self, num_decimals: usize) -> Self
Max number of decimals to show after the decimal point.
If not specified, Self::precision is used instead.
Sourcepub fn with_strip_trailing_zeros(self, strip_trailing_zeros: bool) -> Self
pub fn with_strip_trailing_zeros(self, strip_trailing_zeros: bool) -> Self
Strip trailing zeros from decimal expansion?
Trait Implementations§
Source§impl Clone for FloatFormatOptions
impl Clone for FloatFormatOptions
Source§fn clone(&self) -> FloatFormatOptions
fn clone(&self) -> FloatFormatOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FloatFormatOptions
impl Debug for FloatFormatOptions
Source§impl Hash for FloatFormatOptions
impl Hash for FloatFormatOptions
Source§impl PartialEq for FloatFormatOptions
impl PartialEq for FloatFormatOptions
impl Copy for FloatFormatOptions
impl Eq for FloatFormatOptions
impl StructuralPartialEq for FloatFormatOptions
Auto Trait Implementations§
impl Freeze for FloatFormatOptions
impl RefUnwindSafe for FloatFormatOptions
impl Send for FloatFormatOptions
impl Sync for FloatFormatOptions
impl Unpin for FloatFormatOptions
impl UnwindSafe for FloatFormatOptions
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
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>
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>
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