Hello,
i have thinking i have i have seen through the work of the owernship,borrowing and lifetime system from rust.
So:
pub fn play(adress: &str) {
let location = &ini["mpv"]["location"];
let location_test = r"c:\PortableApps\play.exe";
let process = Command::new(mpv_location_test)
.arg (&adress);
// .output();
process.spawn();
}
still output:
error[E0716]: temporary value dropped while borrowed
--> src\mpv.rs:24:16
|
24 | let process = Command::new(location_test)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
25 | .arg (&adress);
| - temporary value is freed at the end of this statement
26 | // .output();
27 | process.spawn();
| ------- borrow later used here
|
= note: consider using a `let` binding to create a longer lived value
Okay when i call the command in a onliner all is good:
let process = Command::new(mpv_location_test).arg(&adress).output();
And i understand that rust don't can hold the variable-value after the let process
and its gone when i process.output
or spawn
after the creation of process
.
Hmm whats going wrong? Is it why i borrow the variable that i move to location
and why location_test
, its an cool String
or i think an str
?
Thx
Edit: arrrrrgs he mean the &adress
???? But why ????
Edit: Ahhh he means the variable process
, or???? Why process
is freed after use??? But this cannot be when i leave the arg
-method and call after the spawn
all functioned, it must be the adress
-variable???