I'm trying to get nth node of LinkedList and getting this error. Please explain what is wrong with my code?
temporary value dropped while borrowed
creates a temporary which is freed while still in use
note: consider using a
let binding to create a longer lived valuerustc(E0716)
linked_list.rs(31, 26): creates a temporary which is freed while still in use
linked_list.rs(31, 44): temporary value is freed at the end of this statement
linked_list.rs(31, 44): ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type