Buffer api

This commit is contained in:
David Tolnay
2018-08-04 02:11:59 -07:00
parent 1571d45d25
commit ef53abbec4
+15 -2
View File
@@ -1,17 +1,30 @@
use core::str;
use core::{mem, str};
use pretty;
#[derive(Copy, Clone)]
pub struct Buffer {
bytes: [u8; 24],
}
impl Buffer {
pub fn write<F: Float>(&mut self, f: F) -> &str {
pub fn new() -> Self {
Buffer {
bytes: unsafe { mem::uninitialized() },
}
}
pub fn format<F: Float>(&mut self, f: F) -> &str {
f.write_to_ryu_buffer(self)
}
}
impl Default for Buffer {
fn default() -> Self {
Buffer::new()
}
}
pub trait Float: Sealed {
#[doc(hidden)]
fn write_to_ryu_buffer(self, buffer: &mut Buffer) -> &str;