Trait ToSci

Source
pub trait ToSci: Sized {
    // Required methods
    fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result;
    fn fmt_sci_valid(&self, options: ToSciOptions) -> bool;

    // Provided methods
    fn to_sci_with_options(&self, options: ToSciOptions) -> SciWrapper<'_, Self> { ... }
    fn to_sci(&self) -> SciWrapper<'_, Self> { ... }
}
Expand description

Converts a number to a string, possibly in scientific notation.

Required Methods§

Source

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Formats a number, possibly in scientific notation.

Source

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether some formatting options can be applied to a number.

Provided Methods§

Source

fn to_sci_with_options(&self, options: ToSciOptions) -> SciWrapper<'_, Self>

Converts a number to a string, possibly in scientific notation.

Source

fn to_sci(&self) -> SciWrapper<'_, Self>

Converts a number to a string, possibly in scientific notation, using the default ToSciOptions.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ToSci for i8

Source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether a signed number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Converts a signed number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Source§

impl ToSci for i16

Source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether a signed number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Converts a signed number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Source§

impl ToSci for i32

Source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether a signed number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Converts a signed number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Source§

impl ToSci for i64

Source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether a signed number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Converts a signed number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Source§

impl ToSci for i128

Source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether a signed number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Converts a signed number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Source§

impl ToSci for isize

Source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether a signed number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Converts a signed number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Source§

impl ToSci for u8

Source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether an unsigned number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Converts an unsigned number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Source§

impl ToSci for u16

Source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether an unsigned number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Converts an unsigned number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Source§

impl ToSci for u32

Source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether an unsigned number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Converts an unsigned number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Source§

impl ToSci for u64

Source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether an unsigned number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Converts an unsigned number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Source§

impl ToSci for u128

Source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether an unsigned number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Converts an unsigned number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Source§

impl ToSci for usize

Source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether an unsigned number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result

Converts an unsigned number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Implementors§