Function stackfmt::fmt_truncate[][src]

pub fn fmt_truncate<'a>(buffer: &'a mut [u8], args: Arguments<'_>) -> &'a str
Expand description

Writes formatted string into the buffer truncating if needed making the result valid utf8.

Example:

let mut buf = [0u8; 6];
let formatted: &str = stackfmt::fmt_truncate(&mut buf, format_args!("Hello{}", 42));
assert_eq!(formatted, "Hello4");