fmt_tools/format_args_owned.rs
1/// Like [`format_args`](`::core::format_args`), but takes ownership of its arguments.
2///
3/// Example:
4///
5/// ```rust
6/// let fmt = {
7/// let value_1 = vec![2];
8/// let value_2 = Box::new('A');
9/// let value_3 = Box::new(5);
10///
11/// fmt_tools::format_args_owned!("{:?}, {named}, {value_3}", value_1, named = value_2)
12/// };
13///
14/// assert_eq!(format!("{fmt:?}"), "[2], A, 5");
15/// assert_eq!(format!("{fmt}"), "[2], A, 5");
16/// ```
17#[macro_export]
18macro_rules! format_args_owned {
19 ($($args:tt)*) => {
20 $crate::fmt_fn(
21 move |__fmt_tools_formatter| ::core::fmt::Display::fmt(
22 &::core::format_args!($($args)*),
23 __fmt_tools_formatter,
24 )
25 )
26 };
27}