A &'static str
is a string literal e.g. let a : &'static str = "hello world"
. It exists throughout the lifetime of the application.
If you're creating a new String
, then that string is not static!
Simply return a vector of String
.
fn foo() -> Vec<String> {
let mut vec = Vec::new();
let mut string = String::new();
// doing something with string...
vec.push(string);
return vec;
}
fn main() {
foo();
}