You have managed to create a self-referential list.
Here’s what happened.
// You created a list, this list's lifetime parameter ('a) is currently unbound
let mut list = List::new();
// You add an item to the list, and set selected_item
// This binds the lifetime 'a to the lifetime of list
// Note: this means that because you are mutable borrowing here
// Rust will think that you are mutable borrowing for the entirety of 'a
// Now because 'a == lifetime of list, you are now mutable borrowing
// for the rest of list's lifetime
// You try to get an immutable borrow of list, which conflicts with the
// mutable borrow from earlier
even though I am talking about (im)mutable references, it will be much more useful to think of &mut T and &Tas compile time locks (similar idea to thread locks). Where &mut T means unique lock, and &T means shared lock.
Here is a rust playground link for your original example.
The previous reply is completely correct. I’d just like to add that it’s specifically very difficult to use structs where the fields borrow from each other (e.g. the selected_item borrowing from items). I’ve made a modified playground to the above where I replaced selected_item: Option<&'a mut i32> with selected_item_idx: Option<usize>, which works more easily in this case.
The guys have already pointed the problem, so I will add a very very small note : in such positions, you can use an “index” not “a reference”, i.e. you keep the position of the selected element in the list not the reference to it and when no element is selected you can keep an unrealistic value (such as -1) than you can change this integer index freely because it become independant from the vector (from Rust point of view).