Struct num_format::Buffer [−][src]
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); }
Implementations
impl Buffer
[src]
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.