pub struct Options {}
Expand description
Immutable options to customize writing integers.
§Examples
use core::str;
use lexical_write_integer::{Options, ToLexicalWithOptions};
use lexical_write_integer::format::STANDARD;
const OPTIONS: Options = Options::builder()
.build_strict();
const BUFFER_SIZE: usize = OPTIONS.buffer_size_const::<u64, STANDARD>();
let mut buffer = [0u8; BUFFER_SIZE];
let value = 1234u64;
let digits = value.to_lexical_with_options::<STANDARD>(&mut buffer, &OPTIONS);
assert_eq!(str::from_utf8(digits), Ok("1234"));
Implementations§
Source§impl Options
impl Options
Sourcepub const fn from_radix(_: u8) -> Self
Available on crate feature power-of-two
only.
pub const fn from_radix(_: u8) -> Self
power-of-two
only.Create the default options for a given radix.
Sourcepub const fn buffer_size_const<T: FormattedSize, const FORMAT: u128>(
&self,
) -> usize
pub const fn buffer_size_const<T: FormattedSize, const FORMAT: u128>( &self, ) -> usize
Get an upper bound on the required buffer size.
This is always FORMATTED_SIZE
or FORMATTED_SIZE_DECIMAL
,
depending on the radix.
Sourcepub const fn builder() -> OptionsBuilder
pub const fn builder() -> OptionsBuilder
Get OptionsBuilder
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 Ord for Options
impl Ord for Options
Source§impl PartialOrd for Options
impl PartialOrd for Options
Source§impl WriteOptions for Options
impl WriteOptions for Options
Source§fn buffer_size<T: FormattedSize, const FORMAT: u128>(&self) -> usize
👎Deprecated: Use buffer_size_const
instead. Will be removed in 2.0.
fn buffer_size<T: FormattedSize, const FORMAT: u128>(&self) -> usize
buffer_size_const
instead. Will be removed in 2.0.Get an upper bound on the required buffer size.
This method is soft-deprecated and meant for internal use.
You should always use buffer_size_const
so you can get
the required buffer size at compile time to determine the
buffer size required.
This is used when custom formatting options, such as significant
digits specifiers or custom exponent breaks, are used, which
can lead to more or less significant digits being written than
expected. If using the default formatting options, then this will
always be FORMATTED_SIZE
or
FORMATTED_SIZE_DECIMAL
,
depending on the radix.