I\'m trying to concatenate static strings and string literals to build another static string. The following is the best I could come up with, but it doesn\'t work:
The compiler error is
error: expected a literal
A literal is anything you type directly like "hello"
or 5
. The moment you start working with constants, you are not using literals anymore, but identifiers. So right now the best you can do is
const VERSION_STRING: &'static str =
concat!("my program v", env!("CARGO_PKG_VERSION"));
Since the env!
macro expands to a literal, you can use it inside concat!
.