pub struct BaseFmtWrapper<T> { /* private fields */ }
Expand description

A struct that allows for formatting a numeric type and rendering its digits in a specified base.

Implementations§

Creates a new BaseFmtWrapper.

Worst-case complexity

Constant time and additional memory.

Panics

Panics if base is less than 2 or greater than 36.

Examples
use malachite_base::num::conversion::string::to_string::BaseFmtWrapper;

let x = BaseFmtWrapper::new(1000000000u32, 36);
assert_eq!(format!("{}", x), "gjdgxs");
assert_eq!(format!("{:#}", x), "GJDGXS");

Recovers the value from a BaseFmtWrapper.

Worst-case complexity

Constant time and additional memory.

Examples
use malachite_base::num::conversion::string::to_string::BaseFmtWrapper;

assert_eq!(BaseFmtWrapper::new(1000000000u32, 36).unwrap(), 1000000000);

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Writes a wrapped signed number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

Unlike with the default implementations of Binary, Octal, LowerHex, and UpperHex, negative numbers are represented using a negative sign, not two’s complement.

This is the same as the Display::fmt implementation.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped signed number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

Unlike with the default implementations of Binary, Octal, LowerHex, and UpperHex, negative numbers are represented using a negative sign, not two’s complement.

This is the same as the Display::fmt implementation.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped signed number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

Unlike with the default implementations of Binary, Octal, LowerHex, and UpperHex, negative numbers are represented using a negative sign, not two’s complement.

This is the same as the Display::fmt implementation.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped signed number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

Unlike with the default implementations of Binary, Octal, LowerHex, and UpperHex, negative numbers are represented using a negative sign, not two’s complement.

This is the same as the Display::fmt implementation.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped signed number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

Unlike with the default implementations of Binary, Octal, LowerHex, and UpperHex, negative numbers are represented using a negative sign, not two’s complement.

This is the same as the Display::fmt implementation.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped signed number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

Unlike with the default implementations of Binary, Octal, LowerHex, and UpperHex, negative numbers are represented using a negative sign, not two’s complement.

This is the same as the Display::fmt implementation.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped unsigned number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

This is the same as the Display::fmt implementation.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped unsigned number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

This is the same as the Display::fmt implementation.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped unsigned number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

This is the same as the Display::fmt implementation.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped unsigned number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

This is the same as the Display::fmt implementation.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped unsigned number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

This is the same as the Display::fmt implementation.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped unsigned number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

This is the same as the Display::fmt implementation.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped signed number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

Unlike with the default implementations of Binary, Octal, LowerHex, and UpperHex, negative numbers are represented using a negative sign, not two’s complement.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped signed number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

Unlike with the default implementations of Binary, Octal, LowerHex, and UpperHex, negative numbers are represented using a negative sign, not two’s complement.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped signed number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

Unlike with the default implementations of Binary, Octal, LowerHex, and UpperHex, negative numbers are represented using a negative sign, not two’s complement.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped signed number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

Unlike with the default implementations of Binary, Octal, LowerHex, and UpperHex, negative numbers are represented using a negative sign, not two’s complement.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped signed number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

Unlike with the default implementations of Binary, Octal, LowerHex, and UpperHex, negative numbers are represented using a negative sign, not two’s complement.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped signed number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

Unlike with the default implementations of Binary, Octal, LowerHex, and UpperHex, negative numbers are represented using a negative sign, not two’s complement.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped unsigned number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped unsigned number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped unsigned number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped unsigned number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped unsigned number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

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 base is less than 2 or greater than 36.

Examples

See here.

Writes a wrapped unsigned number to a string using a specified base.

If the base is greater than 10, lowercase alphabetic letters are used by default. Using the # flag switches to uppercase letters. Padding with zeros works as usual.

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 base is less than 2 or greater than 36.

Examples

See here.

Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

Returns the String produced by Ts Debug implementation.

Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.