[rust-dev] purely function red-black tree

Patrick Walton pwalton at mozilla.com
Sat Dec 15 11:46:18 PST 2012


On 12/15/12 8:58 AM, Benjamin Striegel wrote:
> 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?

Yes, probably, although it shouldn't have @s in it for the benefit of 
those who don't want to use the garbage collector.

> 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!

It's not possible in 0.5.

Patrick



More information about the Rust-dev mailing list