Formatting Tools
Fast, minimal, feature-rich, extended formatting syntax for Rust!
Features include:
- Arbitrary expressions inside the formatting braces
- Generates optimized Rust code at compiletime
- Supports rust-analyzer auto complete, refactoring and more!
- Supports Rust's standard formatting specifiers
- Single package, no proc-macro, no_std compatible, no extra dependencies
- Control flow allows conditional and repeated formatting
- Capture variables by value or by reference
- Escape hatch to inject custom formatting code
In your Cargo.toml, add:
[dependencies]
fmtools = "0.1"
Examples
Basic usage
assert_eq!;
The value arguments can be arbitrary expressions. They are inlined in the formatting braces and are outside the string literals.
Formatting specifiers
assert_eq!;
The rules for the specifiers are exactly the same as the standard library of Rust.
Let bindings
assert_eq!;
Introduce new variable bindings to hold onto temporary values used in the formatting.
Control flow
assert_eq!;
assert_eq!;
assert_eq!;
Control flow really shows the added value of the extended formatting syntax.
Capture by value
assert_eq!;
The displayable object can own the captured variables with move
and can be returned from functions.
Escape hatch
assert_eq!;
Closure syntax provides an escape hatch to inject code if needed.
The argument's type is &mut Formatter
.
License
Licensed under MIT License, see license.txt.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.