#format #stack #formatted #string #alloc #write #buffer

no-std stackfmt

Write formatted string to a buffer without alloc

3 releases

0.1.2 Nov 12, 2021
0.1.1 Jul 20, 2021
0.1.0 Jul 19, 2021

#235 in No standard library

Download history 24/week @ 2024-01-08 165/week @ 2024-01-15 47/week @ 2024-01-22 16/week @ 2024-01-29 37/week @ 2024-02-05 56/week @ 2024-02-12 8/week @ 2024-02-19 18/week @ 2024-02-26 157/week @ 2024-03-04 1/week @ 2024-03-11 74/week @ 2024-03-18 54/week @ 2024-03-25 213/week @ 2024-04-01 148/week @ 2024-04-08 64/week @ 2024-04-15

479 downloads per month
Used in utf8conv

MIT license

9KB
140 lines

stackfmt

Creates formatted string from format_args!() like alloc::fmt::format() but without allocation:

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

Implemented based on this SO answer https://stackoverflow.com/a/50201632/601298


lib.rs:

Creates formatted string from [format_args!()] like alloc::fmt::format() but without allocation:

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

Implemented based on this SO answer https://stackoverflow.com/a/50201632/601298

No runtime deps