You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the following code errors with list does not live long enough error in rust 2021 edition
#[test]fnpeek(){letmut list = List::new();assert!(list.peek_front().is_none());
list.push_front(1); list.push_front(2); list.push_front(3);assert_eq!(&*list.peek_front().unwrap(), &3);// --> `list` does not live long enough (borrowed value does not live long enough)}
but the following code works:
#[test]fnpeek(){letmut list = List::new();assert!(list.peek_front().is_none());
list.push_front(1); list.push_front(2); list.push_front(3);// not a good namelet elem:i32 = list.peek_front().unwrap();assert_eq!(elem, 3);}
The text was updated successfully, but these errors were encountered:
the following code errors with
list
does not live long enough error in rust 2021 editionbut the following code works:
The text was updated successfully, but these errors were encountered: