Crates.io | pformat_macro |
lib.rs | pformat_macro |
version | 0.0.1 |
source | src |
created_at | 2022-06-27 11:57:45.44834 |
updated_at | 2022-06-27 11:57:45.44834 |
description | Simple format_args!-like macro whose result can be stored for later use |
homepage | |
repository | https://github.com/egor-vaskon/pformat_macro |
max_upload_size | |
id | 614080 |
size | 17,043 |
format_args!
macroRust standard library has format_args!
macro that lets
you combine format string and its arguments into the Arguments
structure
without allocations in cost of directly referencing parts of format string,
so the result must be used immediately (to satisfy borrow checker).
This crates offers pformat_args!
macro that returns impl Display
instance
that can be used just like any normal structure holding provided format arguments.
pformat_args = { git = "https://github.com/egor-vaskon/pformat_macro" }
The usage is almost the same as format_args!
except that all {}
placeholders must be empty.
use pformat_macro::pformat_args;
fn main() {
let result_str = pformat_args!("1 + 1 = {}", 3);
println!("{}", result_str) //prints 1 + 1 = 3
}
Licensed under The MIT License