Let binding on string assignment

I'm literally translating NodeJS path normalization into Rust. Few lines are getting:

temporary value dropped while borrowed
consider using a `let` binding to create a longer lived valuerustcE0716
path_helpers.rs(88, 140): temporary value is freed at the end of this statement
path_helpers.rs(104, 18): borrow later used here

Full source: flx/path_helpers.rs at master · flxsdk/flx · GitHub

The error above is on this line (88):

res = path[(if last_slash.is_none() { 0 } else { last_slash.unwrap() + 1})..i].into_iter().collect::<String>().as_ref();

I tried separating these expressions with let.

I had to use let mut res: String;