Function cookie_factory::bytes::ne_f32
source · pub fn ne_f32<W: Write>(i: f32) -> impl SerializeFn<W>
Expand description
Writes an f32
in native byte order to the output
use cookie_factory::{gen, bytes::ne_f32};
let mut buf = [0u8; 100];
{
let (buf, pos) = gen(ne_f32(1.0f32), &mut buf[..]).unwrap();
assert_eq!(pos, 4);
assert_eq!(buf.len(), 100 - 4);
}
#[cfg(target_endian = "big")]
assert_eq!(&buf[..4], &[63u8, 128u8, 0u8, 0u8][..]);
#[cfg(target_endian = "little")]
assert_eq!(&buf[..4], &[0u8, 0u8, 128u8, 63u8][..]);