formatx 0.3.0

A macro for formatting non literal strings at runtime in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use formatx::formatxl;

fn main() {
    // i18n example: templates with possibly missing arguments
    let templates = [
        ("en", "Hello {name}, welcome to {place}!"),
        ("es", "Hola {name}, bienvenido a {place}!"),
        ("ja", "{name}さん、{place}へようこそ!"),
    ];

    for (lang, template) in templates {
        // Lenient mode: missing "place" won't error
        let result = formatxl!(template, name = "Alice").unwrap();
        println!("[{lang}] {result}");
    }
}