ifmt

Inline expression interpolation for Rust

5 releases

✓ Uses Rust 2018 edition

0.2.0 Jun 6, 2019
0.1.3 May 26, 2019
0.1.2 May 8, 2019
0.1.1 May 7, 2019
0.1.0 Apr 20, 2019

#144 in Rust patterns

47 downloads per month

MIT/Apache

5KB

ifmt

A small crate which brings inline string interpolation to rust's standard formatting macros.

Getting started

To use ifmt in your project, add

[dependencies]
ifmt = "0.2.0"

to your Cargo.toml.

Examples

let four = 4;
iprintln!("four plus four is: {four + 4}");
// four plus four is: 8
iprintln!("here's a hex number: 0x{0xb0bi64 * 1321517i64 :x}");
// here's a hex number: 0xdeadbeef
iprintln!("here's a debugging value: {Some(four):?}");
// here's a debugging value: Some(4)

Supported macros

format!      -> iformat!
print!       -> iprint!
println!     -> iprintln!
eprint!      -> ieprint!
eprintln!    -> ieprintln!
write!       -> iwrite!
writeln!     -> iwriteln!
panic!       -> ipanic!
format_args! -> iformat_args!

License

This project is licensed under the MIT license or the Apache 2.0 license at your option.


lib.rs:

A small crate which brings inline string interpolation to rust's standard formatting macros.

Examples

use ifmt::iprintln;
let four = 4;
iprintln!("four plus four is: {four + 4}");
// four plus four is: 8
iprintln!("here's a hex number: 0x{0xb0bi64 * 1321517i64 :x}");
// here's a hex number: 0xdeadbeef
iprintln!("here's a debugging value: {Some(four):?}");
// here's a debugging value: Some(4)

Supported macros

format!      -> iformat!
print!       -> iprint!
println!     -> iprintln!
eprint!      -> ieprint!
eprintln!    -> ieprintln!
write!       -> iwrite!
writeln!     -> iwriteln!
format_args! -> iformat_args!

Dependencies

~2.5MB
~49K SLoC