mozilla/rust — pull request #11453 by TisButMe (2014-01-10 14:11:34+00:00)
Title: Completely rewrote the list lib

Better:
-> No use of the @pointers anymore
-> Has methods instead of functions
-> Fully tested and documented

New:
-> Provides copying/referencing/moving iterators, which implement the Iterator trait (which wasn't the case before. This allows the use of the all "free" methods which come with this trait, as well as the 'for in' syntax.
-> Implements FromIterator trait, which allows this collection to play nice with collect() and similar.
-> Has a prepend method. (Furthermore, it is efficiently implemented: no copying)
-> Has an insert method
-> Has methods to access an element by its index (either copying -at() or []-, referencing -at_ref()- or mutably referencing -at_ref_mut()-)
-> Generally tries to play with the standard Traits instead of re-inventing the wheel.

Good:
-> No use at all of unsafe code, or unsafe pointers.

TODO:
-> At the moment, the FromIterator implementation is naive, and uses repeated append()s which will first go through the whole list. I tried keeping a ref to the last Cell (which should be easy since append() returns a &mut to the last cell), but lifetime management defeated me...
-> Add a MutRef iterator. I started working on this, but can't figure out where I'm going wrong or how to side-step the issue (see http://stackoverflow.com/questions/20993909/borrow-vs-mutable-borrow-strange-failure-in-lifetimes)