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");
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 for BaseFmtWrapper<T>
impl<T: PartialEq> PartialEq for BaseFmtWrapper<T>
impl<T: Eq> Eq for BaseFmtWrapper<T>
impl<T> StructuralPartialEq for BaseFmtWrapper<T>
Auto Trait Implementations§
impl<T> Freeze for BaseFmtWrapper<T>where
T: Freeze,
impl<T> RefUnwindSafe for BaseFmtWrapper<T>where
T: RefUnwindSafe,
impl<T> Send for BaseFmtWrapper<T>where
T: Send,
impl<T> Sync for BaseFmtWrapper<T>where
T: Sync,
impl<T> Unpin for BaseFmtWrapper<T>where
T: Unpin,
impl<T> UnwindSafe for BaseFmtWrapper<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more