[][src]Struct num_format::Buffer

pub struct Buffer { /* fields omitted */ }

A key type. Represents a stack-allocated buffer you can use to get a formatted &str without heap allocation.

Example

use num_format::{Buffer, Locale};

fn main() {
    // Create a stack-allocated buffer...
    let mut buf = Buffer::default();

    // Write "1,000,000" into the buffer...
    buf.write_formatted(&1000000, &Locale::en);

    // Get a view into the buffer as a &str...
    let s = buf.as_str();

    // Do what you want with the &str...
    assert_eq!("1,000,000", s);
}

Methods

impl Buffer[src]

pub fn new() -> Buffer[src]

Constructs a new, stack-allocated buffer.

pub fn as_bytes(&self) -> &[u8][src]

Returns a &[u8] view into the buffer.

pub fn as_str(&self) -> &str[src]

Returns a &str view into the buffer.

pub fn is_empty(&self) -> bool[src]

Returns true if the buffer is empty; false otherwise.

pub fn len(&self) -> usize[src]

Returns the length (in bytes) of the buffer.

pub fn write_formatted<F, N>(&mut self, n: &N, format: &F) -> usize where
    F: Format,
    N: ToFormattedStr
[src]

Writes the provided number into the buffer using the provided format.

Trait Implementations

impl Default for Buffer[src]

fn default() -> Buffer[src]

Same as the new method.

impl Clone for Buffer[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for Buffer[src]

impl AsRef<str> for Buffer[src]

impl Display for Buffer[src]

impl Debug for Buffer[src]

impl Deref for Buffer[src]

type Target = str

The resulting type after dereferencing.

impl Borrow<str> for Buffer[src]

Auto Trait Implementations

impl Send for Buffer

impl Sync for Buffer

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.