#const #format #format-string #no-alloc #no-std #const-format

macro no-std static_format

Format strings with no runtime overhead

3 releases

0.0.3 Jan 9, 2024
0.0.2 Jan 9, 2024
0.0.1 Jan 9, 2024

#901 in Text processing

Download history 18/week @ 2024-01-05 4/week @ 2024-02-16 21/week @ 2024-02-23 7/week @ 2024-03-01 76/week @ 2024-03-22 28/week @ 2024-03-29

104 downloads per month

MIT license

9KB
178 lines

Const Format

A simple macro which just makes concat! more ergonomic / easier to read.

use static_format::const_format;

macro_rules! period {
    () => {'.'}
}

fn main() {
    let formatted = const_format!(
        "{}, there are {} formatted {}{}",
        "Hello", 4, "arguments", period!()
    );
    assert_eq!(formatted, "Hello, there are 4 formatted arguments.");
}

Dependencies

~285–730KB
~17K SLoC