1 Cannot return value that references local variable
3 Local variables, function parameters and temporaries are all dropped before the
4 end of the function body. So a reference to them cannot be returned.
6 Erroneous code example:
9 fn get_dangling_reference() -> &'static i32 {
17 fn get_dangling_iterator<'a>() -> Iter<'a, i32> {
18 let v = vec![1, 2, 3];
23 Consider returning an owned value instead:
26 use std::vec::IntoIter;
28 fn get_integer() -> i32 {
33 fn get_owned_iterator() -> IntoIter<i32> {
34 let v = vec![1, 2, 3];