lexical_core

Struct NumberFormatBuilder

Source
pub struct NumberFormatBuilder { /* private fields */ }
Expand description

Build number format from specifications.

Returns the format on calling build if it was able to compile the format, otherwise, returns None.

§Fields

  • digit_separator - Character to separate digits.
  • mantissa_radix - Radix for mantissa digits.
  • exponent_base - Base for the exponent.
  • exponent_radix - Radix for the exponent digits.
  • base_prefix - Optional character for the base prefix.
  • base_suffix - Optional character for the base suffix.
  • required_integer_digits - If digits are required before the decimal point.
  • required_fraction_digits - If digits are required after the decimal point.
  • required_exponent_digits - If digits are required after the exponent character.
  • required_mantissa_digits - If at least 1 significant digit is required.
  • no_positive_mantissa_sign - If positive sign before the mantissa is not allowed.
  • required_mantissa_sign - If positive sign before the mantissa is required.
  • no_exponent_notation - If exponent notation is not allowed.
  • no_positive_exponent_sign - If positive sign before the exponent is not allowed.
  • required_exponent_sign - If sign before the exponent is required.
  • no_exponent_without_fraction - If exponent without fraction is not allowed.
  • no_special - If special (non-finite) values are not allowed.
  • case_sensitive_special - If special (non-finite) values are case-sensitive.
  • no_integer_leading_zeros - If leading zeros before an integer are not allowed.
  • no_float_leading_zeros - If leading zeros before a float are not allowed.
  • required_exponent_notation - If exponent notation is required.
  • case_sensitive_exponent - If exponent characters are case-sensitive.
  • case_sensitive_base_prefix - If base prefixes are case-sensitive.
  • case_sensitive_base_suffix - If base suffixes are case-sensitive.
  • integer_internal_digit_separator - If digit separators are allowed between integer digits.
  • fraction_internal_digit_separator - If digit separators are allowed between fraction digits.
  • exponent_internal_digit_separator - If digit separators are allowed between exponent digits.
  • integer_leading_digit_separator - If a digit separator is allowed before any integer digits.
  • fraction_leading_digit_separator - If a digit separator is allowed before any fraction digits.
  • exponent_leading_digit_separator - If a digit separator is allowed before any exponent digits.
  • integer_trailing_digit_separator - If a digit separator is allowed after any integer digits.
  • fraction_trailing_digit_separator - If a digit separator is allowed after any fraction digits.
  • exponent_trailing_digit_separator - If a digit separator is allowed after any exponent digits.
  • integer_consecutive_digit_separator - If multiple consecutive integer digit separators are allowed.
  • fraction_consecutive_digit_separator - If multiple consecutive fraction digit separators are allowed.
  • special_digit_separator - If any digit separators are allowed in special (non-finite) values.

§Write Integer Fields

No fields are used for writing integers.

§Parse Integer Fields

These fields are used for parsing integers:

  • digit_separator
  • mantissa_radix
  • base_prefix
  • base_suffix
  • no_positive_mantissa_sign
  • required_mantissa_sign
  • no_integer_leading_zeros
  • integer_internal_digit_separator
  • integer_leading_digit_separator
  • integer_trailing_digit_separator
  • integer_consecutive_digit_separator

§Write Float Fields

These fields are used for writing floats:

  • mantissa_radix
  • exponent_base
  • exponent_radix
  • no_positive_mantissa_sign
  • required_mantissa_sign
  • no_exponent_notation
  • no_positive_exponent_sign
  • required_exponent_sign
  • required_exponent_notation

§Parse Float Fields

These fields are used for parsing floats:

  • digit_separator
  • mantissa_radix
  • exponent_base
  • exponent_radix
  • base_prefix
  • base_suffix
  • required_integer_digits
  • required_fraction_digits
  • required_exponent_digits
  • no_positive_mantissa_sign
  • required_mantissa_sign
  • no_exponent_notation
  • no_positive_exponent_sign
  • required_exponent_sign
  • no_exponent_without_fraction
  • no_special
  • case_sensitive_special
  • no_integer_leading_zeros
  • no_float_leading_zeros
  • required_exponent_notation
  • case_sensitive_exponent
  • case_sensitive_base_prefix
  • case_sensitive_base_suffix
  • integer_internal_digit_separator
  • fraction_internal_digit_separator
  • exponent_internal_digit_separator
  • integer_leading_digit_separator
  • fraction_leading_digit_separator
  • exponent_leading_digit_separator
  • integer_trailing_digit_separator
  • fraction_trailing_digit_separator
  • exponent_trailing_digit_separator
  • integer_consecutive_digit_separator
  • fraction_consecutive_digit_separator
  • special_digit_separator

Implementations§

Source§

impl NumberFormatBuilder

Source

pub const fn new() -> NumberFormatBuilder

Create new NumberFormatBuilder with default arguments.

Source

pub const fn decimal() -> u128

Create number format for standard, decimal number.

Source

pub const fn get_digit_separator(&self) -> Option<NonZero<u8>>

Get the digit separator for the number format.

Source

pub const fn get_mantissa_radix(&self) -> u8

Get the radix for mantissa digits.

Source

pub const fn get_exponent_base(&self) -> Option<NonZero<u8>>

Get the radix for the exponent.

Source

pub const fn get_exponent_radix(&self) -> Option<NonZero<u8>>

Get the radix for exponent digits.

Source

pub const fn get_base_prefix(&self) -> Option<NonZero<u8>>

Get the optional character for the base prefix.

Source

pub const fn get_base_suffix(&self) -> Option<NonZero<u8>>

Get the optional character for the base suffix.

Source

pub const fn get_required_integer_digits(&self) -> bool

Get if digits are required before the decimal point.

Source

pub const fn get_required_fraction_digits(&self) -> bool

Get if digits are required after the decimal point.

Source

pub const fn get_required_exponent_digits(&self) -> bool

Get if digits are required after the exponent character.

Source

pub const fn get_required_mantissa_digits(&self) -> bool

Get if at least 1 significant digit is required.

Source

pub const fn get_no_positive_mantissa_sign(&self) -> bool

Get if a positive sign before the mantissa is not allowed.

Source

pub const fn get_required_mantissa_sign(&self) -> bool

Get if a sign symbol before the mantissa is required.

Source

pub const fn get_no_exponent_notation(&self) -> bool

Get if exponent notation is not allowed.

Source

pub const fn get_no_positive_exponent_sign(&self) -> bool

Get if a positive sign before the exponent is not allowed.

Source

pub const fn get_required_exponent_sign(&self) -> bool

Get if a sign symbol before the exponent is required.

Source

pub const fn get_no_exponent_without_fraction(&self) -> bool

Get if an exponent without fraction is not allowed.

Source

pub const fn get_no_special(&self) -> bool

Get if special (non-finite) values are not allowed.

Source

pub const fn get_case_sensitive_special(&self) -> bool

Get if special (non-finite) values are case-sensitive.

Source

pub const fn get_no_integer_leading_zeros(&self) -> bool

Get if leading zeros before an integer are not allowed.

Source

pub const fn get_no_float_leading_zeros(&self) -> bool

Get if leading zeros before a float are not allowed.

Source

pub const fn get_required_exponent_notation(&self) -> bool

Get if exponent notation is required.

Source

pub const fn get_case_sensitive_exponent(&self) -> bool

Get if exponent characters are case-sensitive.

Source

pub const fn get_case_sensitive_base_prefix(&self) -> bool

Get if base prefixes are case-sensitive.

Source

pub const fn get_case_sensitive_base_suffix(&self) -> bool

Get if base suffixes are case-sensitive.

Source

pub const fn get_integer_internal_digit_separator(&self) -> bool

Get if digit separators are allowed between integer digits.

Source

pub const fn get_fraction_internal_digit_separator(&self) -> bool

Get if digit separators are allowed between fraction digits.

Source

pub const fn get_exponent_internal_digit_separator(&self) -> bool

Get if digit separators are allowed between exponent digits.

Source

pub const fn get_integer_leading_digit_separator(&self) -> bool

Get if a digit separator is allowed before any integer digits.

Source

pub const fn get_fraction_leading_digit_separator(&self) -> bool

Get if a digit separator is allowed before any fraction digits.

Source

pub const fn get_exponent_leading_digit_separator(&self) -> bool

Get if a digit separator is allowed before any exponent digits.

Source

pub const fn get_integer_trailing_digit_separator(&self) -> bool

Get if a digit separator is allowed after any integer digits.

Source

pub const fn get_fraction_trailing_digit_separator(&self) -> bool

Get if a digit separator is allowed after any fraction digits.

Source

pub const fn get_exponent_trailing_digit_separator(&self) -> bool

Get if a digit separator is allowed after any exponent digits.

Source

pub const fn get_integer_consecutive_digit_separator(&self) -> bool

Get if multiple consecutive integer digit separators are allowed.

Source

pub const fn get_fraction_consecutive_digit_separator(&self) -> bool

Get if multiple consecutive fraction digit separators are allowed.

Source

pub const fn get_exponent_consecutive_digit_separator(&self) -> bool

Get if multiple consecutive exponent digit separators are allowed.

Source

pub const fn get_special_digit_separator(&self) -> bool

Get if any digit separators are allowed in special (non-finite) values.

Source

pub const fn build(&self) -> u128

Create 128-bit, packed number format struct from builder options.

NOTE: This function will never fail, due to issues with panicking (and therefore unwrapping Errors/Options) in const fns. It is therefore up to you to ensure the format is valid, called via the is_valid function on NumberFormat.

Source

pub const fn rebuild(format: u128) -> NumberFormatBuilder

Re-create builder from format.

Trait Implementations§

Source§

impl Default for NumberFormatBuilder

Source§

fn default() -> NumberFormatBuilder

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

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> 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, 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.