I am trying to declare a const String
in stable Rust but it does not let me declare it:
const CONSTANT_VALUE: String = String::from("constant value");
fn main() {
println!("{}", TARGET_PORT_KEY);
}
It is saying that:
Calls in constants are limited to tuple structs and tuple variants
I do not want to declare my string
as literal and call to_string()
on literal all the time.
What is the correct way to declare a constant String
value?