[−][src]Struct num_format::Buffer
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]
F: Format,
N: ToFormattedStr,
Writes the provided number into the buffer using the provided format.
Trait Implementations
impl Default for Buffer
[src]
impl Clone for Buffer
[src]
fn clone(&self) -> 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]
impl Borrow<str> for Buffer
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,