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 unsafe fn set_max_significant_digits(
&mut self,
max_significant_digits: Option<NonZero<usize>>,
)
pub unsafe fn set_max_significant_digits( &mut self, max_significant_digits: Option<NonZero<usize>>, )
Set the maximum number of significant digits to write. Unsafe, use the builder API for option validation.
§Safety
Always safe, just marked as unsafe for API compatibility.
Sourcepub unsafe fn set_min_significant_digits(
&mut self,
min_significant_digits: Option<NonZero<usize>>,
)
pub unsafe fn set_min_significant_digits( &mut self, min_significant_digits: Option<NonZero<usize>>, )
Set the minimum number of significant digits to write. Unsafe, use the builder API for option validation.
§Safety
Always safe, just marked as unsafe for API compatibility.
Sourcepub unsafe fn set_positive_exponent_break(
&mut self,
positive_exponent_break: Option<NonZero<i32>>,
)
pub unsafe fn set_positive_exponent_break( &mut self, positive_exponent_break: Option<NonZero<i32>>, )
Set the maximum exponent prior to using scientific notation.
§Safety
Always safe, just marked as unsafe for API compatibility.
Sourcepub unsafe fn set_negative_exponent_break(
&mut self,
negative_exponent_break: Option<NonZero<i32>>,
)
pub unsafe fn set_negative_exponent_break( &mut self, negative_exponent_break: Option<NonZero<i32>>, )
Set the minimum exponent prior to using scientific notation.
§Safety
Always safe, just marked as unsafe for API compatibility.
Sourcepub unsafe fn set_round_mode(&mut self, round_mode: RoundMode)
pub unsafe fn set_round_mode(&mut self, round_mode: RoundMode)
Set the rounding mode for writing digits with precision control.
§Safety
Always safe, just marked as unsafe for API compatibility.
Sourcepub unsafe fn set_trim_floats(&mut self, trim_floats: bool)
pub unsafe fn set_trim_floats(&mut self, trim_floats: bool)
Set if we should trim a trailing ".0"
from floats.
Unsafe, use the builder API for option validation.
§Safety
Always safe, just marked as unsafe for API compatibility.
Sourcepub unsafe fn set_exponent(&mut self, exponent: u8)
pub unsafe 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 unsafe fn set_decimal_point(&mut self, decimal_point: u8)
pub unsafe 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 unsafe fn set_nan_string(&mut self, nan_string: Option<&'static [u8]>)
pub unsafe fn set_nan_string(&mut self, nan_string: Option<&'static [u8]>)
Set the string representation for NaN
.
Unsafe, use the builder API for option validation.
§Safety
Unsafe if nan_string.len() > MAX_SPECIAL_STRING_LENGTH
. This might
cause a special string larger than the buffer length to be written,
causing a buffer overflow, potentially a severe security vulnerability.
Sourcepub unsafe fn set_inf_string(&mut self, inf_string: Option<&'static [u8]>)
pub unsafe fn set_inf_string(&mut self, inf_string: Option<&'static [u8]>)
Set the short string representation for Infinity
Unsafe, use the builder API for option validation.
§Safety
Unsafe if nan_string.len() > MAX_SPECIAL_STRING_LENGTH
. This might
cause a special string larger than the buffer length to be written,
causing a buffer overflow, potentially a severe security vulnerability.
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
)