I have one vector which is immutable and another which is mutable and of different type. I am trying to find a way to modify the values from String to str and append them to mutable vector.
Like this:
let mut args = vec!["a", "b", "c"];
if let Some(additional_args) = optional_args {
for p in additional_args {
args.push("--added");
args.push(p.clone().as_str());
}
}
optional_args is of type Option<Vec<String>>.
This gives me an error that temporary value dropped while borrowed.
Is there anyway to clone the value, modify it and push into args?