Struct malachite_base::num::conversion::string::to_string::BaseFmtWrapper
source · 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§
source§impl<T> BaseFmtWrapper<T>
impl<T> BaseFmtWrapper<T>
sourcepub fn new(x: T, base: u8) -> Self
pub fn new(x: T, base: u8) -> Self
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");sourcepub fn unwrap(self) -> T
pub fn unwrap(self) -> T
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§
source§impl<T: Clone> Clone for BaseFmtWrapper<T>
impl<T: Clone> Clone for BaseFmtWrapper<T>
source§fn clone(&self) -> BaseFmtWrapper<T>
fn clone(&self) -> BaseFmtWrapper<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for BaseFmtWrapper<i128>
impl Debug for BaseFmtWrapper<i128>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Debug for BaseFmtWrapper<i16>
impl Debug for BaseFmtWrapper<i16>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Debug for BaseFmtWrapper<i32>
impl Debug for BaseFmtWrapper<i32>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Debug for BaseFmtWrapper<i64>
impl Debug for BaseFmtWrapper<i64>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Debug for BaseFmtWrapper<i8>
impl Debug for BaseFmtWrapper<i8>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Debug for BaseFmtWrapper<isize>
impl Debug for BaseFmtWrapper<isize>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Debug for BaseFmtWrapper<u128>
impl Debug for BaseFmtWrapper<u128>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Debug for BaseFmtWrapper<u16>
impl Debug for BaseFmtWrapper<u16>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Debug for BaseFmtWrapper<u32>
impl Debug for BaseFmtWrapper<u32>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Debug for BaseFmtWrapper<u64>
impl Debug for BaseFmtWrapper<u64>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Debug for BaseFmtWrapper<u8>
impl Debug for BaseFmtWrapper<u8>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Debug for BaseFmtWrapper<usize>
impl Debug for BaseFmtWrapper<usize>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Display for BaseFmtWrapper<i128>
impl Display for BaseFmtWrapper<i128>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Display for BaseFmtWrapper<i16>
impl Display for BaseFmtWrapper<i16>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Display for BaseFmtWrapper<i32>
impl Display for BaseFmtWrapper<i32>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Display for BaseFmtWrapper<i64>
impl Display for BaseFmtWrapper<i64>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Display for BaseFmtWrapper<i8>
impl Display for BaseFmtWrapper<i8>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Display for BaseFmtWrapper<isize>
impl Display for BaseFmtWrapper<isize>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Display for BaseFmtWrapper<u128>
impl Display for BaseFmtWrapper<u128>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Display for BaseFmtWrapper<u16>
impl Display for BaseFmtWrapper<u16>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Display for BaseFmtWrapper<u32>
impl Display for BaseFmtWrapper<u32>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Display for BaseFmtWrapper<u64>
impl Display for BaseFmtWrapper<u64>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Display for BaseFmtWrapper<u8>
impl Display for BaseFmtWrapper<u8>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl Display for BaseFmtWrapper<usize>
impl Display for BaseFmtWrapper<usize>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
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.
source§impl<T: Hash> Hash for BaseFmtWrapper<T>
impl<T: Hash> Hash for BaseFmtWrapper<T>
source§impl<T: PartialEq> PartialEq<BaseFmtWrapper<T>> for BaseFmtWrapper<T>
impl<T: PartialEq> PartialEq<BaseFmtWrapper<T>> for BaseFmtWrapper<T>
source§fn eq(&self, other: &BaseFmtWrapper<T>) -> bool
fn eq(&self, other: &BaseFmtWrapper<T>) -> bool
self and other values to be equal, and is used
by ==.