With new versions of Rust, you can simplify structure initialization like this:
Foo {
a: a,
b: b,
}
to this
Foo { a, b }
Is it possible to do something similar for format!/println!-like macros?
For now I need to write it like this:
let a = "a";
let b = "b";
write!(file, "{a} is {b}", a = a, b = b).unwrap();
Is it possible to write my own macros with an API like this:
let a = "a";
let b = "b";
my_write!(file, "{a} is {b}", a, b).unwrap();
write!(file, "{} is {}", a, b), orwrite!(file, "{0} is {1}", a, b).{long_word},{another_long_word}awith the string value"a"is likely confusing your example, especially with the text"{a} is {b}". Try using something concrete likenameandageinstead.ato be intepreted asa = ain formatters, like it allowsato be short fora: ain struct initializers. The answer is No AFAIK?