Struct lexical_write_float::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 max_significant_digits(&self) -> OptionUsize
pub const fn max_significant_digits(&self) -> OptionUsize
Get the maximum number of significant digits to write.
sourcepub const fn min_significant_digits(&self) -> OptionUsize
pub const fn min_significant_digits(&self) -> OptionUsize
Get the minimum number of significant digits to write.
sourcepub const fn positive_exponent_break(&self) -> OptionI32
pub const fn positive_exponent_break(&self) -> OptionI32
Get the maximum exponent prior to using scientific notation.
sourcepub const fn negative_exponent_break(&self) -> OptionI32
pub const fn negative_exponent_break(&self) -> OptionI32
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: OptionUsize,
)
pub unsafe fn set_max_significant_digits( &mut self, max_significant_digits: OptionUsize, )
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: OptionUsize,
)
pub unsafe fn set_min_significant_digits( &mut self, min_significant_digits: OptionUsize, )
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: OptionI32,
)
pub unsafe fn set_positive_exponent_break( &mut self, positive_exponent_break: OptionI32, )
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: OptionI32,
)
pub unsafe fn set_negative_exponent_break( &mut self, negative_exponent_break: OptionI32, )
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 PartialEq for Options
impl PartialEq for Options
source§impl WriteOptions for Options
impl WriteOptions for Options
source§fn buffer_size<T: FormattedSize, const FORMAT: u128>(&self) -> usize
fn buffer_size<T: FormattedSize, const FORMAT: u128>(&self) -> usize
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)