Function ryu::raw::f2s_buffered_n [] [src]

pub unsafe fn f2s_buffered_n(f: f32, result: *mut u8) -> usize

Print f32 to the given buffer and return number of bytes written.

At most 15 bytes will be written.

Special cases

This function represents any NaN as NaN, positive infinity as Infinity, and negative infinity as -Infinity.

Safety

The result pointer argument must point to sufficiently many writable bytes to hold Ryū's representation of f.

Example

let f = 1.234f32;

unsafe {
    let mut buffer: [u8; 15] = std::mem::uninitialized();
    let n = ryu::raw::f2s_buffered_n(f, &mut buffer[0]);
    let s = std::str::from_utf8_unchecked(&buffer[..n]);
    assert_eq!(s, "1.234E0");
}