I'm trying to define a constant format string that is used in a number of places with the format!
macro.
I've tried something like:
const FORMAT_A: &'static str = "a: {}";
static FORMAT_B: &'static str = "b: {}";
fn main() {
format!(FORMAT_A, "a");
format!(FORMAT_B, "b");
}
However, this fails to compile with:
error: format argument must be a string literal.
--> src/main.rs:5:13
|
5 | format!(FORMAT_A, "a");
| ^^^^^^^^
error: format argument must be a string literal.
--> src/main.rs:6:13
|
6 | format!(FORMAT_B, "b");
| ^^^^^^^^
Is there another way I should be defining a constant string literal to use with format!
?