Struct NumBuffer

pub struct NumBuffer<T: NumBufferTrait> { pub(crate) buf: T::Buf, pub(in ::fmt::num_buffer) phantom: PhantomData<T> }

Memory for formatting numbers using [T::format_into()][u8::format_into].

This type consists of enough memory to hold the longest decimal string representation a number of type T could have. It is used only by calling format_into(); there is no other way to access its contents. Its purpose is to allow formatting numbers without involving the dynamic dispatch of the fmt system, which may be more efficient when fmt is not otherwise used.

Examples

use core::fmt::NumBuffer;

let mut buf = NumBuffer::new();
let n1 = 1972u32;
assert_eq!(n1.format_into(&mut buf), "1972");

// Formatting a negative integer includes the sign.
let mut buf = NumBuffer::new();
let n2 = -1972i32;
assert_eq!(n2.format_into(&mut buf), "-1972");

Fields

buf: T::Buf
phantom: PhantomData<T>

Implementations

impl<T: NumBufferTrait> NumBuffer<T>

const fn new() -> Self

Initializes internal buffer.

Trait Implementations

impl<T: NumBufferTrait> Debug for NumBuffer<T>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<T: NumBufferTrait> Default for NumBuffer<T>

fn default() -> Self

Auto Trait Implementations

impl<T> Freeze for NumBuffer<T> where <T as NumBufferTrait>::Buf: Freeze, PhantomData<T>: Freeze,

impl<T> RefUnwindSafe for NumBuffer<T> where <T as NumBufferTrait>::Buf: RefUnwindSafe, PhantomData<T>: RefUnwindSafe,

impl<T> Send for NumBuffer<T> where <T as NumBufferTrait>::Buf: Send, PhantomData<T>: Send,

impl<T> Sync for NumBuffer<T> where <T as NumBufferTrait>::Buf: Sync, PhantomData<T>: Sync,

impl<T> Unpin for NumBuffer<T> where <T as NumBufferTrait>::Buf: Unpin, PhantomData<T>: Unpin,

impl<T> UnsafeUnpin for NumBuffer<T> where <T as NumBufferTrait>::Buf: UnsafeUnpin, PhantomData<T>: UnsafeUnpin,

impl<T> UnwindSafe for NumBuffer<T> where <T as NumBufferTrait>::Buf: UnwindSafe, PhantomData<T>: UnwindSafe,

Blanket Implementations

impl<T> Any for NumBuffer<T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for NumBuffer<T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for NumBuffer<T> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for NumBuffer<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for NumBuffer<T> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for NumBuffer<T>

impl<T, U> Into<U> for NumBuffer<T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for NumBuffer<T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for NumBuffer<T> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>