Crate reusable_fmt[][src]

Expand description

This crate provides compile-time defined format strings support for std::fmt macros.

Example

use reusable_fmt::*;

// This defines your format strings
fmt_reuse! {
    TEST1 = "This is a test! {}";
    TEST2 = "You can pass multiple format args! {} {}";
    TEST3 = r#"Raw Strings work too!! {}"#;
    TEST4 = "Named args {arg}";
    TEST5 = "Positional args {1} {0}";
    TEST6 = "Mixed {} {2} {1} {arg}";
}

fn main() {
	prntln!(TEST1, "Hello World"); // This is a test! Hello World
	let test = fmt!(TEST6, "Hello", "Test", "World", arg="Named"); // Mixed Hello World Test Named
	prntln!("{}", "WOW This works too!");
}

Syntax

Format strings are explicitly defined using the fmt_reuse! macro first

All format related macros follow a syntax similar to std::fmt macros (and even support the same syntax as them!)

The general syntax is:

fmt!(<KEY>, <ARGUMENTS>)

wrt!(<BUFFER>, <KEY>, <ARGUMENTS>)

Macros

eprnt

Wrapper around eprintln!

eprntln

Wrapper around eprintln!

fmt

Wrapper around format!

fmt_reuse

Creates a reusable format identifier

prnt

Wrapper around print!

prntln

Wrapper around println!

wrt

Wrapper around write!

wrtln

Wrapper around writeln!