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
sourceimpl<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
sourceimpl<T: Clone> Clone for BaseFmtWrapper<T>
impl<T: Clone> Clone for BaseFmtWrapper<T>
sourcefn clone(&self) -> BaseFmtWrapper<T>
fn clone(&self) -> BaseFmtWrapper<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for BaseFmtWrapper<u8>
impl Debug for BaseFmtWrapper<u8>
sourcefn 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.
sourceimpl Debug for BaseFmtWrapper<u16>
impl Debug for BaseFmtWrapper<u16>
sourcefn 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.
sourceimpl Debug for BaseFmtWrapper<i128>
impl Debug for BaseFmtWrapper<i128>
sourcefn 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.
sourceimpl Debug for BaseFmtWrapper<isize>
impl Debug for BaseFmtWrapper<isize>
sourcefn 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.
sourceimpl Debug for BaseFmtWrapper<u32>
impl Debug for BaseFmtWrapper<u32>
sourcefn 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.
sourceimpl Debug for BaseFmtWrapper<u64>
impl Debug for BaseFmtWrapper<u64>
sourcefn 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.
sourceimpl Debug for BaseFmtWrapper<u128>
impl Debug for BaseFmtWrapper<u128>
sourcefn 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.
sourceimpl Debug for BaseFmtWrapper<usize>
impl Debug for BaseFmtWrapper<usize>
sourcefn 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.
sourceimpl Debug for BaseFmtWrapper<i8>
impl Debug for BaseFmtWrapper<i8>
sourcefn 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.
sourceimpl Debug for BaseFmtWrapper<i16>
impl Debug for BaseFmtWrapper<i16>
sourcefn 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.
sourceimpl Debug for BaseFmtWrapper<i32>
impl Debug for BaseFmtWrapper<i32>
sourcefn 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.
sourceimpl Debug for BaseFmtWrapper<i64>
impl Debug for BaseFmtWrapper<i64>
sourcefn 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.
sourceimpl Display for BaseFmtWrapper<u8>
impl Display for BaseFmtWrapper<u8>
sourcefn 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.
sourceimpl Display for BaseFmtWrapper<u16>
impl Display for BaseFmtWrapper<u16>
sourcefn 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.
sourceimpl Display for BaseFmtWrapper<i128>
impl Display for BaseFmtWrapper<i128>
sourcefn 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.
sourceimpl Display for BaseFmtWrapper<isize>
impl Display for BaseFmtWrapper<isize>
sourcefn 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.
sourceimpl Display for BaseFmtWrapper<u32>
impl Display for BaseFmtWrapper<u32>
sourcefn 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.
sourceimpl Display for BaseFmtWrapper<u64>
impl Display for BaseFmtWrapper<u64>
sourcefn 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.
sourceimpl Display for BaseFmtWrapper<u128>
impl Display for BaseFmtWrapper<u128>
sourcefn 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.
sourceimpl Display for BaseFmtWrapper<usize>
impl Display for BaseFmtWrapper<usize>
sourcefn 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.
sourceimpl Display for BaseFmtWrapper<i8>
impl Display for BaseFmtWrapper<i8>
sourcefn 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.
sourceimpl Display for BaseFmtWrapper<i16>
impl Display for BaseFmtWrapper<i16>
sourcefn 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.
sourceimpl Display for BaseFmtWrapper<i32>
impl Display for BaseFmtWrapper<i32>
sourcefn 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.
sourceimpl Display for BaseFmtWrapper<i64>
impl Display for BaseFmtWrapper<i64>
sourcefn 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.
sourceimpl<T: Hash> Hash for BaseFmtWrapper<T>
impl<T: Hash> Hash for BaseFmtWrapper<T>
sourceimpl<T: PartialEq> PartialEq<BaseFmtWrapper<T>> for BaseFmtWrapper<T>
impl<T: PartialEq> PartialEq<BaseFmtWrapper<T>> for BaseFmtWrapper<T>
sourcefn eq(&self, other: &BaseFmtWrapper<T>) -> bool
fn eq(&self, other: &BaseFmtWrapper<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &BaseFmtWrapper<T>) -> bool
fn ne(&self, other: &BaseFmtWrapper<T>) -> bool
This method tests for !=
.
impl<T: Eq> Eq for BaseFmtWrapper<T>
impl<T> StructuralEq for BaseFmtWrapper<T>
impl<T> StructuralPartialEq for BaseFmtWrapper<T>
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more