WriteIntegerOptions

Struct WriteIntegerOptions 

Source
pub struct WriteIntegerOptions {}
Available on crate feature write-integers only.
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

Source

pub const fn new() -> Options

Create options with default values.

Source

pub const fn from_radix(_: u8) -> Options

Create the default options for a given radix.

Source

pub const fn is_valid(&self) -> bool

Check if the options state is valid.

Source

pub const fn buffer_size_const<T, const FORMAT: u128>(&self) -> usize
where T: FormattedSize,

Get an upper bound on the required buffer size.

This is always FORMATTED_SIZE or FORMATTED_SIZE_DECIMAL, depending on the radix.

Source

pub const fn builder() -> OptionsBuilder

Get OptionsBuilder as a static function.

Source

pub const fn rebuild(&self) -> OptionsBuilder

Create OptionsBuilder using existing values.

Trait Implementations§

Source§

impl Clone for Options

Source§

fn clone(&self) -> Options

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Options

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Options

Source§

fn default() -> Options

Returns the “default value” for a type. Read more
Source§

impl Ord for Options

Source§

fn cmp(&self, other: &Options) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Options

Source§

fn eq(&self, other: &Options) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Options

Source§

fn partial_cmp(&self, other: &Options) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl WriteOptions for Options

Source§

fn buffer_size<T, const FORMAT: u128>(&self) -> usize
where T: FormattedSize,

👎Deprecated: Use 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.

Source§

fn is_valid(&self) -> bool

Determine if the options are valid.
Source§

impl Eq for Options

Source§

impl StructuralPartialEq for Options

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.