30 lines
651 B
Rust
30 lines
651 B
Rust
use std::io::Write;
|
|
use crate::ser::error::Result;
|
|
use super::{RealFormat, WriteReal};
|
|
|
|
macro_rules! impl_write_real_for_fast_format {
|
|
($($prim:ident with $xtoa:ident),*) => {
|
|
$(impl WriteReal<$prim> for FastRealFormat {
|
|
fn write_real<W: Write>(w: &mut W, r: $prim) -> Result<()> {
|
|
$xtoa::write(w, r).map(|_| ()).map_err(|e| e.into())
|
|
}
|
|
})*
|
|
}
|
|
}
|
|
|
|
pub struct FastRealFormat;
|
|
|
|
impl_write_real_for_fast_format!(
|
|
i8 with itoa,
|
|
i16 with itoa,
|
|
i32 with itoa,
|
|
i64 with itoa,
|
|
u8 with itoa,
|
|
u16 with itoa,
|
|
u32 with itoa,
|
|
u64 with itoa,
|
|
f32 with dtoa,
|
|
f64 with dtoa
|
|
);
|
|
|
|
impl RealFormat for FastRealFormat {} |