pub struct WriteFloatOptions { /* private fields */ }
Expand description
Options to customize writing floats.
§Examples
use lexical_write_float::Options;
let options = Options::builder()
.trim_floats(true)
.nan_string(Some(b"NaN"))
.inf_string(Some(b"Inf"))
.build()
.unwrap();
Implementations§
Source§impl Options
impl Options
Sourcepub const fn max_significant_digits(&self) -> Option<NonZero<usize>>
pub const fn max_significant_digits(&self) -> Option<NonZero<usize>>
Get the maximum number of significant digits to write.
Sourcepub const fn min_significant_digits(&self) -> Option<NonZero<usize>>
pub const fn min_significant_digits(&self) -> Option<NonZero<usize>>
Get the minimum number of significant digits to write.
Sourcepub const fn positive_exponent_break(&self) -> Option<NonZero<i32>>
pub const fn positive_exponent_break(&self) -> Option<NonZero<i32>>
Get the maximum exponent prior to using scientific notation.
Sourcepub const fn negative_exponent_break(&self) -> Option<NonZero<i32>>
pub const fn negative_exponent_break(&self) -> Option<NonZero<i32>>
Get the minimum exponent prior to using scientific notation.
Sourcepub const fn round_mode(&self) -> RoundMode
pub const fn round_mode(&self) -> RoundMode
Get the rounding mode for writing digits with precision control.
Sourcepub const fn trim_floats(&self) -> bool
pub const fn trim_floats(&self) -> bool
Get if we should trim a trailing ".0"
from floats.
Sourcepub const fn exponent(&self) -> u8
pub const fn exponent(&self) -> u8
Get the character to designate the exponent component of a float.
Sourcepub const fn decimal_point(&self) -> u8
pub const fn decimal_point(&self) -> u8
Get the character to separate the integer from the fraction components.
Sourcepub const fn nan_string(&self) -> Option<&'static [u8]>
pub const fn nan_string(&self) -> Option<&'static [u8]>
Get the string representation for NaN
.
Sourcepub const fn inf_string(&self) -> Option<&'static [u8]>
pub const fn inf_string(&self) -> Option<&'static [u8]>
Get the short string representation for Infinity
.
Sourcepub fn set_max_significant_digits(
&mut self,
max_significant_digits: Option<NonZero<usize>>,
)
pub fn set_max_significant_digits( &mut self, max_significant_digits: Option<NonZero<usize>>, )
Set the maximum number of significant digits to write.
Sourcepub fn set_min_significant_digits(
&mut self,
min_significant_digits: Option<NonZero<usize>>,
)
pub fn set_min_significant_digits( &mut self, min_significant_digits: Option<NonZero<usize>>, )
Set the minimum number of significant digits to write.
Sourcepub fn set_positive_exponent_break(
&mut self,
positive_exponent_break: Option<NonZero<i32>>,
)
pub fn set_positive_exponent_break( &mut self, positive_exponent_break: Option<NonZero<i32>>, )
Set the maximum exponent prior to using scientific notation.
Sourcepub fn set_negative_exponent_break(
&mut self,
negative_exponent_break: Option<NonZero<i32>>,
)
pub fn set_negative_exponent_break( &mut self, negative_exponent_break: Option<NonZero<i32>>, )
Set the minimum exponent prior to using scientific notation.
Sourcepub fn set_round_mode(&mut self, round_mode: RoundMode)
pub fn set_round_mode(&mut self, round_mode: RoundMode)
Set the rounding mode for writing digits with precision control.
Sourcepub fn set_trim_floats(&mut self, trim_floats: bool)
pub fn set_trim_floats(&mut self, trim_floats: bool)
Set if we should trim a trailing ".0"
from floats.
Sourcepub fn set_exponent(&mut self, exponent: u8)
pub fn set_exponent(&mut self, exponent: u8)
Set the character to designate the exponent component of a float.
§Safety
Always safe, but may produce invalid output if the exponent is not a valid ASCII character.
Sourcepub fn set_decimal_point(&mut self, decimal_point: u8)
pub fn set_decimal_point(&mut self, decimal_point: u8)
Set the character to separate the integer from the fraction components.
§Safety
Always safe, but may produce invalid output if the decimal point is not a valid ASCII character.
Sourcepub fn set_nan_string(&mut self, nan_string: Option<&'static [u8]>)
pub fn set_nan_string(&mut self, nan_string: Option<&'static [u8]>)
Set the string representation for NaN
.
Panics
Setting a value too large may cause a panic even if FORMATTED_SIZE
elements are provided.
Sourcepub fn set_inf_string(&mut self, inf_string: Option<&'static [u8]>)
pub fn set_inf_string(&mut self, inf_string: Option<&'static [u8]>)
Set the short string representation for Infinity
Panics
Setting a value too large may cause a panic even if FORMATTED_SIZE
elements are provided.
Sourcepub const fn builder() -> OptionsBuilder
pub const fn builder() -> OptionsBuilder
Get WriteFloatOptionsBuilder
as a static function.
Sourcepub const fn rebuild(&self) -> OptionsBuilder
pub const fn rebuild(&self) -> OptionsBuilder
Create OptionsBuilder
using existing values.