Compiler says there's temporary value that ends lifetime but i don't know how to prevent this.
fn connectPesel(Names: &mut Vec<&str>){
let mut rng = rand::thread_rng();
for i in 0..Names.len(){
Names[i] = format!("{} {}", Names[i], rng.gen_range(1000..9999)).as_str();
}
}
13 | fn connectPesel(Names: &mut Vec<&str>){
| - let's call the lifetime of this reference `'1`
...
16 | Names[i] = format!("{} {}", Names[i], rng.gen_range(1000..9999)).as_str();
| -----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------- temporary value is freed at the end of this statement
| | |
| | creates a temporary which is freed while still in use
| assignment requires that borrow lasts for `'1`
|