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
sourceimpl 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<NonZeroUsize>
pub const fn max_significant_digits(&self) -> Option<NonZeroUsize>
Get the maximum number of significant digits to write.
sourcepub const fn min_significant_digits(&self) -> Option<NonZeroUsize>
pub const fn min_significant_digits(&self) -> Option<NonZeroUsize>
Get the minimum number of significant digits to write.
sourcepub const fn positive_exponent_break(&self) -> Option<NonZeroI32>
pub const fn positive_exponent_break(&self) -> Option<NonZeroI32>
Get the maximum exponent prior to using scientific notation.
sourcepub const fn negative_exponent_break(&self) -> Option<NonZeroI32>
pub const fn negative_exponent_break(&self) -> Option<NonZeroI32>
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<NonZeroUsize>
)
pub unsafe fn set_max_significant_digits(
&mut self,
max_significant_digits: Option<NonZeroUsize>
)
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<NonZeroUsize>
)
pub unsafe fn set_min_significant_digits(
&mut self,
min_significant_digits: Option<NonZeroUsize>
)
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<NonZeroI32>
)
pub unsafe fn set_positive_exponent_break(
&mut self,
positive_exponent_break: Option<NonZeroI32>
)
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<NonZeroI32>
)
pub unsafe fn set_negative_exponent_break(
&mut self,
negative_exponent_break: Option<NonZeroI32>
)
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
sourceimpl WriteOptions for Options
impl WriteOptions for Options
sourcefn buffer_size<T, const FORMAT: u128>(&self) -> usize where
T: FormattedSize,
fn buffer_size<T, const FORMAT: u128>(&self) -> usize where
T: FormattedSize,
Get an upper bound on the buffer size.
impl Eq for Options
impl StructuralEq for Options
impl StructuralPartialEq for Options
Auto Trait Implementations
impl RefUnwindSafe for Options
impl Send for Options
impl Sync for Options
impl Unpin for Options
impl UnwindSafe for Options
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more