Skip to main content

GmpFormatArg

Trait GmpFormatArg 

Source
pub trait GmpFormatArg {
    // Required method
    fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>;

    // Provided method
    fn printf_int(&self) -> Option<i64> { ... }
}
Expand description

A value that can be consumed by a conversion of a GMP-style format string; see gmp_format.

Each implementation accepts the conversions its library counterpart would: Natural and Integer take %Z integer conversions, Rational takes %Q, Float takes %R, primitive integers take the plain C integer conversions (and %c), char takes %c, and strings take %s. gmp_format returns the formatted piece, or None when the specification does not apply to the value’s type.

Required Methods§

Source

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats this value according to a single parsed conversion specification, or returns None when the specification does not apply to this type.

Provided Methods§

Source

fn printf_int(&self) -> Option<i64>

The integer consumed by a * field width or precision, when this value is a primitive integer that fits in an i64.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl GmpFormatArg for &str

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats a string according to a single parsed conversion specification, which must be a %s conversion with no type character. As in C, the precision is the maximum number of bytes written; if that limit would split a multi-byte character, None is returned, since the output could not be a valid string.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is max(self.len(), w), with w the field width requested by the format string.

§Examples

See here.

Source§

impl GmpFormatArg for String

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats a string according to a single parsed conversion specification; see the &str implementation.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is max(self.len(), w), with w the field width requested by the format string.

§Examples

See here.

Source§

impl GmpFormatArg for char

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats a char according to a single parsed conversion specification, which must be a %c conversion with no type character.

§Worst-case complexity

$T(w) = O(w)$

$M(w) = O(w)$

where $T$ is time, $M$ is additional memory, and $w$ is the field width stored in spec: the character itself is constant-size, but the output is padded to the field width.

§Examples

See here.

Source§

impl GmpFormatArg for i8

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats a signed primitive integer according to a single parsed conversion specification: a plain C integer conversion (d, i, u, o, x, or X, with any C length modifier accepted but not truncating the value, and a negative value keeping its sign under every conversion), or c (keeping the value’s lowest byte, as C does).

§Worst-case complexity

$T(n, w, p) = O(n + w + p)$

$M(n, w, p) = O(n + w + p)$

where $T$ is time, $M$ is additional memory, $n$ is self.significant_bits(), $w$ is the field width stored in spec, and $p$ is the precision stored in spec: rendering the digits is linear in the value’s bits, and padding to the field width or precision is linear in those settings.

§Examples

See here.

Source§

fn printf_int(&self) -> Option<i64>

Source§

impl GmpFormatArg for i16

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats a signed primitive integer according to a single parsed conversion specification: a plain C integer conversion (d, i, u, o, x, or X, with any C length modifier accepted but not truncating the value, and a negative value keeping its sign under every conversion), or c (keeping the value’s lowest byte, as C does).

§Worst-case complexity

$T(n, w, p) = O(n + w + p)$

$M(n, w, p) = O(n + w + p)$

where $T$ is time, $M$ is additional memory, $n$ is self.significant_bits(), $w$ is the field width stored in spec, and $p$ is the precision stored in spec: rendering the digits is linear in the value’s bits, and padding to the field width or precision is linear in those settings.

§Examples

See here.

Source§

fn printf_int(&self) -> Option<i64>

Source§

impl GmpFormatArg for i32

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats a signed primitive integer according to a single parsed conversion specification: a plain C integer conversion (d, i, u, o, x, or X, with any C length modifier accepted but not truncating the value, and a negative value keeping its sign under every conversion), or c (keeping the value’s lowest byte, as C does).

§Worst-case complexity

$T(n, w, p) = O(n + w + p)$

$M(n, w, p) = O(n + w + p)$

where $T$ is time, $M$ is additional memory, $n$ is self.significant_bits(), $w$ is the field width stored in spec, and $p$ is the precision stored in spec: rendering the digits is linear in the value’s bits, and padding to the field width or precision is linear in those settings.

§Examples

See here.

Source§

fn printf_int(&self) -> Option<i64>

Source§

impl GmpFormatArg for i64

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats a signed primitive integer according to a single parsed conversion specification: a plain C integer conversion (d, i, u, o, x, or X, with any C length modifier accepted but not truncating the value, and a negative value keeping its sign under every conversion), or c (keeping the value’s lowest byte, as C does).

§Worst-case complexity

$T(n, w, p) = O(n + w + p)$

$M(n, w, p) = O(n + w + p)$

where $T$ is time, $M$ is additional memory, $n$ is self.significant_bits(), $w$ is the field width stored in spec, and $p$ is the precision stored in spec: rendering the digits is linear in the value’s bits, and padding to the field width or precision is linear in those settings.

§Examples

See here.

Source§

fn printf_int(&self) -> Option<i64>

Source§

impl GmpFormatArg for i128

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats a signed primitive integer according to a single parsed conversion specification: a plain C integer conversion (d, i, u, o, x, or X, with any C length modifier accepted but not truncating the value, and a negative value keeping its sign under every conversion), or c (keeping the value’s lowest byte, as C does).

§Worst-case complexity

$T(n, w, p) = O(n + w + p)$

$M(n, w, p) = O(n + w + p)$

where $T$ is time, $M$ is additional memory, $n$ is self.significant_bits(), $w$ is the field width stored in spec, and $p$ is the precision stored in spec: rendering the digits is linear in the value’s bits, and padding to the field width or precision is linear in those settings.

§Examples

See here.

Source§

fn printf_int(&self) -> Option<i64>

Source§

impl GmpFormatArg for isize

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats a signed primitive integer according to a single parsed conversion specification: a plain C integer conversion (d, i, u, o, x, or X, with any C length modifier accepted but not truncating the value, and a negative value keeping its sign under every conversion), or c (keeping the value’s lowest byte, as C does).

§Worst-case complexity

$T(n, w, p) = O(n + w + p)$

$M(n, w, p) = O(n + w + p)$

where $T$ is time, $M$ is additional memory, $n$ is self.significant_bits(), $w$ is the field width stored in spec, and $p$ is the precision stored in spec: rendering the digits is linear in the value’s bits, and padding to the field width or precision is linear in those settings.

§Examples

See here.

Source§

fn printf_int(&self) -> Option<i64>

Source§

impl GmpFormatArg for u8

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats an unsigned primitive integer according to a single parsed conversion specification: a plain C integer conversion (d, i, u, o, x, or X, with any C length modifier accepted but not truncating the value), or c (keeping the value’s lowest byte, as C does).

§Worst-case complexity

$T(n, w, p) = O(n + w + p)$

$M(n, w, p) = O(n + w + p)$

where $T$ is time, $M$ is additional memory, $n$ is self.significant_bits(), $w$ is the field width stored in spec, and $p$ is the precision stored in spec: rendering the digits is linear in the value’s bits, and padding to the field width or precision is linear in those settings.

§Examples

See here.

Source§

fn printf_int(&self) -> Option<i64>

Source§

impl GmpFormatArg for u16

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats an unsigned primitive integer according to a single parsed conversion specification: a plain C integer conversion (d, i, u, o, x, or X, with any C length modifier accepted but not truncating the value), or c (keeping the value’s lowest byte, as C does).

§Worst-case complexity

$T(n, w, p) = O(n + w + p)$

$M(n, w, p) = O(n + w + p)$

where $T$ is time, $M$ is additional memory, $n$ is self.significant_bits(), $w$ is the field width stored in spec, and $p$ is the precision stored in spec: rendering the digits is linear in the value’s bits, and padding to the field width or precision is linear in those settings.

§Examples

See here.

Source§

fn printf_int(&self) -> Option<i64>

Source§

impl GmpFormatArg for u32

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats an unsigned primitive integer according to a single parsed conversion specification: a plain C integer conversion (d, i, u, o, x, or X, with any C length modifier accepted but not truncating the value), or c (keeping the value’s lowest byte, as C does).

§Worst-case complexity

$T(n, w, p) = O(n + w + p)$

$M(n, w, p) = O(n + w + p)$

where $T$ is time, $M$ is additional memory, $n$ is self.significant_bits(), $w$ is the field width stored in spec, and $p$ is the precision stored in spec: rendering the digits is linear in the value’s bits, and padding to the field width or precision is linear in those settings.

§Examples

See here.

Source§

fn printf_int(&self) -> Option<i64>

Source§

impl GmpFormatArg for u64

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats an unsigned primitive integer according to a single parsed conversion specification: a plain C integer conversion (d, i, u, o, x, or X, with any C length modifier accepted but not truncating the value), or c (keeping the value’s lowest byte, as C does).

§Worst-case complexity

$T(n, w, p) = O(n + w + p)$

$M(n, w, p) = O(n + w + p)$

where $T$ is time, $M$ is additional memory, $n$ is self.significant_bits(), $w$ is the field width stored in spec, and $p$ is the precision stored in spec: rendering the digits is linear in the value’s bits, and padding to the field width or precision is linear in those settings.

§Examples

See here.

Source§

fn printf_int(&self) -> Option<i64>

Source§

impl GmpFormatArg for u128

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats an unsigned primitive integer according to a single parsed conversion specification: a plain C integer conversion (d, i, u, o, x, or X, with any C length modifier accepted but not truncating the value), or c (keeping the value’s lowest byte, as C does).

§Worst-case complexity

$T(n, w, p) = O(n + w + p)$

$M(n, w, p) = O(n + w + p)$

where $T$ is time, $M$ is additional memory, $n$ is self.significant_bits(), $w$ is the field width stored in spec, and $p$ is the precision stored in spec: rendering the digits is linear in the value’s bits, and padding to the field width or precision is linear in those settings.

§Examples

See here.

Source§

fn printf_int(&self) -> Option<i64>

Source§

impl GmpFormatArg for usize

Source§

fn gmp_format(&self, spec: &GmpConversionSpec) -> Option<String>

Formats an unsigned primitive integer according to a single parsed conversion specification: a plain C integer conversion (d, i, u, o, x, or X, with any C length modifier accepted but not truncating the value), or c (keeping the value’s lowest byte, as C does).

§Worst-case complexity

$T(n, w, p) = O(n + w + p)$

$M(n, w, p) = O(n + w + p)$

where $T$ is time, $M$ is additional memory, $n$ is self.significant_bits(), $w$ is the field width stored in spec, and $p$ is the precision stored in spec: rendering the digits is linear in the value’s bits, and padding to the field width or precision is linear in those settings.

§Examples

See here.

Source§

fn printf_int(&self) -> Option<i64>

Implementors§