Struct lexical_core::write_float_options::Options
source · pub struct Options { /* 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 from_radix(radix: u8) -> Options
pub const fn from_radix(radix: u8) -> Options
Create the default options for a given radix.
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.
Trait Implementations§
source§impl WriteOptions for Options
impl WriteOptions for Options
source§fn buffer_size<T, const FORMAT: u128>(&self) -> usizewhere
T: FormattedSize,
fn buffer_size<T, const FORMAT: u128>(&self) -> usizewhere
T: FormattedSize,
impl Eq for Options
impl StructuralPartialEq for Options
Auto Trait Implementations§
impl Freeze for Options
impl RefUnwindSafe for Options
impl Send for Options
impl Sync for Options
impl Unpin for Options
impl UnwindSafe for Options
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)