I am looking for a class similar to Vec<RefCell<T>> , since it is the ultimate owner and distributor of all its data, but different parts of the array can be repeatedly borrowed by several parties for an indefinite period.
I emphasize vaguely because Vec<T> chunks can also be borrowed by several parties, but there is a separation that can only be resolved after the parties are borrowed.
Vec<RefCell<T>> seems like a world of danger and a lot of ugly if checking borrow_state , which seems to be unstable . If you do something wrong, then cabalmo! Panic! This is not what the lending library likes. In the lending library, if you ask for a book that isn't there, they tell you, "Oh, it's written out." No one dies in an explosion.
So I would like to write code something like this:
let mut a = LendingLibrary::new(); a.push(Foo{x:10}); a.push(Foo{x:11}); let b1 = a.get(0);
Is there such a thing? Or is there another canonical way to get this behavior? Some kind of "friendly RefCell"?
If the answer is yes, is there also a streaming option?
source share