Macro format_bytes::write_bytes[][src]

macro_rules! write_bytes {
    #[proc_macro_hack] => { ... };
}

Like format_bytes!, but writes to a stream given as an additional first argument.

The stream is an expression of any type that implements the [WriteBytes] trait. The macro returns Result<(), WriteBytes::Error>.

Examples

use format_bytes::write_bytes;

const BUFFER_LEN: usize = 20;
let mut buffer = [0_u8; BUFFER_LEN];
let mut slice = &mut buffer[..];

write_bytes!(slice, b"{}", 3.14).unwrap();

let written = BUFFER_LEN - slice.len();
assert_eq!(&buffer[..written], b"3.14");