On Wed, Aug 28, 2013 at 8:22 PM, Nicholas Bishop <nicholasbis...@gmail.com> wrote: > Hi, > > I'm new to Rust, currently trying out a few simple tests to get a > handle on things. > > I have a few questions about linked lists. I see there are two list > modules in extra, one for ~ pointers and one for @ pointers. (I'm > using the current trunk rather than 0.7 if that makes a difference.) >
Hi, Nicholas -- There are two list modules because one is a singly linked list -- list.rs -- and one is a doubly linked list -- dlist.rs . Off the top of my head I'm not sure if there's a reason why list.rs uses @ pointers. > The interfaces between the two look quite different however. Is this > because one is newer and the other hasn't caught up yet, or are the > differences by design and the two interfaces will stay more or less as > they are? > I would expect that the interfaces will be different, since one might want to use a doubly-linked list for different purposes than a singly linked list. > In extra::list, I don't see methods to append or remove a single > element. Intentional or todo? Probably to-do. > > In extra::dlist, there are methods to remove the back or front > element, but not an arbitrary link? Probably to-do. > > On a related note, I'd be interested to read about implementing data > structures in Rust. The examples of structs in the tutorial are mostly > very simple (Point, Circle, etc). The use of Rust's pointers get much > more complicated when dealing with non-tree structures. For example, > extra::dlist uses raw pointers rather than @ pointers for links. An > overview of what the tradeoffs look like (code clarity, > memory-leak/memory-corruption issues, performance numbers, memory > usage) and some cookbook patterns could be quite helpful. This would make a great topic for a blog post -- perhaps someone has even already written it! As far as existing code examples go, extra::treemap might be a good one to study. Cheers, Tim -- Tim Chevalier * http://catamorphism.org/ * Often in error, never in doubt "Being queer is not about a right to privacy; it is about the freedom to be public, to just be who we are." -- anonymous, June 1990 _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev