Skip to content

yegorvk/pformat_macro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

format_args! without restrictions

The Rust standard library's format_args! macro combines a format string and its arguments into an Arguments structure without allocations. However, the result must be used immediately to satisfy the borrow checker.

This crate provides the pformat_args! macro, which returns an opaque impl Display instance holding the format string along with the arguments, such that it can be stored for later use.

[dependencies]
pformat_macro = { git = "https://github.com/yegorvk/pformat_macro" }

Usage

The usage is similar to format_args!, but as of the current version, all the {} 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

About

format_args! without restrictions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages