Struct malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper
source · pub struct BaseFmtWrapper<T> { /* private fields */ }
Expand description
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_nz::integer::Integer;
use malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;
use malachite_nz::natural::Natural;
let n = Natural::from(1000000000u32);
let x = BaseFmtWrapper::new(&n, 36);
assert_eq!(format!("{}", x), "gjdgxs");
assert_eq!(format!("{:#}", x), "GJDGXS");
let n = Integer::from(-1000000000);
let x = BaseFmtWrapper::new(&n, 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_nz::natural::conversion::string::to_string::BaseFmtWrapper;
use malachite_nz::natural::Natural;
assert_eq!(
BaseFmtWrapper::new(Natural::from(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<'a> Debug for BaseFmtWrapper<&'a Integer>
impl<'a> Debug for BaseFmtWrapper<&'a Integer>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Writes a wrapped Integer
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 (\log n)^2 \log\log n)$
$M(n) = O(n \log 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
use malachite_nz::integer::Integer;
use malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;
let n = Integer::from(-1000000000);
let x = BaseFmtWrapper::new(&n, 36);
assert_eq!(format!("{:?}", x), "-gjdgxs");
assert_eq!(format!("{:#?}", x), "-GJDGXS");
assert_eq!(format!("{:010?}", x), "-000gjdgxs");
assert_eq!(format!("{:#010?}", x), "-000GJDGXS");
source§impl<'a> Debug for BaseFmtWrapper<&'a Natural>
impl<'a> Debug for BaseFmtWrapper<&'a Natural>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Writes a wrapped Natural
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 (\log n)^2 \log\log n)$
$M(n) = O(n \log 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
use malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;
use malachite_nz::natural::Natural;
let n = Natural::from(1000000000u32);
let x = BaseFmtWrapper::new(&n, 36);
assert_eq!(format!("{:?}", x), "gjdgxs");
assert_eq!(format!("{:#?}", x), "GJDGXS");
assert_eq!(format!("{:010?}", x), "0000gjdgxs");
assert_eq!(format!("{:#010?}", x), "0000GJDGXS");
source§impl<'a> Display for BaseFmtWrapper<&'a Integer>
impl<'a> Display for BaseFmtWrapper<&'a Integer>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Writes a wrapped Integer
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 (\log n)^2 \log\log n)$
$M(n) = O(n \log 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
use malachite_nz::integer::Integer;
use malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;
let n = Integer::from(-1000000000);
let x = BaseFmtWrapper::new(&n, 36);
assert_eq!(format!("{}", x), "-gjdgxs");
assert_eq!(format!("{:#}", x), "-GJDGXS");
assert_eq!(format!("{:010}", x), "-000gjdgxs");
assert_eq!(format!("{:#010}", x), "-000GJDGXS");
source§impl<'a> Display for BaseFmtWrapper<&'a Natural>
impl<'a> Display for BaseFmtWrapper<&'a Natural>
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Writes a wrapped Natural
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 (\log n)^2 \log\log n)$
$M(n) = O(n \log 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
use malachite_nz::natural::conversion::string::to_string::BaseFmtWrapper;
use malachite_nz::natural::Natural;
let n = Natural::from(1000000000u32);
let x = BaseFmtWrapper::new(&n, 36);
assert_eq!(format!("{}", x), "gjdgxs");
assert_eq!(format!("{:#}", x), "GJDGXS");
assert_eq!(format!("{:010}", x), "0000gjdgxs");
assert_eq!(format!("{:#010}", x), "0000GJDGXS");
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