mirror of
https://github.com/openharmony/third_party_rust_ryu.git
synced 2026-07-19 19:13:31 -04:00
Buffer api
This commit is contained in:
+15
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user