Struct re_format::FloatFormatOptions
source · pub struct FloatFormatOptions {
pub always_sign: bool,
pub precision: usize,
pub num_decimals: Option<usize>,
pub strip_trailing_zeros: bool,
}
Expand description
Options for how to format a floating point number, e.g. an f64
.
Fields§
§always_sign: bool
Always show the sign, even if it is positive (+
).
precision: usize
Maximum 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
Implementations§
source§impl FloatFormatOptions
impl FloatFormatOptions
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
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 FloatFormatOptions
impl Debug for FloatFormatOptions
source§impl Hash for FloatFormatOptions
impl Hash for FloatFormatOptions
source§impl PartialEq for FloatFormatOptions
impl PartialEq for FloatFormatOptions
source§fn eq(&self, other: &FloatFormatOptions) -> bool
fn eq(&self, other: &FloatFormatOptions) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.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
Mutably borrows from an owned value. Read more