[rust-dev] purely function red-black tree

Benjamin Striegel ben.striegel at gmail.com
Sat Dec 15 08:58:40 PST 2012


Would this trait:

    pub trait Map<K: Copy Eq Ord, V: Copy> {
      pure fn get(k: K) -> @Option<V>;
      pure fn put(k: K, v: V) -> self;
      pure fn delete(k: K) -> self;
      pure fn traverse(f: fn((&K), (@Option<V>)));
    }

be something that ought to live somewhere in the standard library?

I also see that you have an impl of this trait in which you also define a
bunch of methods that don't belong to the trait. I didn't even know that
was possible! If you feel that those methods (blacken, modifiedWith,
balance, modWith) don't belong in the Map trait, perhaps split their
definitions off into a separate "anonymous" impl for now, and then when 0.5
rolls around you can define a trait that inherits from the Map trait and
requires those additional methods.


On Fri, Dec 14, 2012 at 6:51 PM, Steve Jenson <stevej at fruitless.org> wrote:

> I recently ported Matt Might's Scala port of Okasaki's purely functional
> red-black tree to Rust and am looking for some feedback.
>
> https://github.com/stevej/rustled/blob/master/red_black_tree.rs
>
> I've written this for 0.4 and will update it with other feedback I've
> received for 0.5 when that lands.
>
> Thanks!
> Steve
>
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20121215/9bce191c/attachment.html>


More information about the Rust-dev mailing list