[rust-dev] purely function red-black tree

Steve Jenson stevej at fruitless.org
Sat Dec 15 16:38:57 PST 2012

On Sat, Dec 15, 2012 at 11:46 AM, Patrick Walton <pwalton at mozilla.com>wrote:

> 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 could use advice here. Is it possible for me to write a single trait that
can be used by both users that want to use managed boxes and people who
wish otherwise? IOW, what is the best way to abstract away the @sign in
this trait?

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

What is the rationale for making this impossible?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20121215/88c2d2e1/attachment.html>

More information about the Rust-dev mailing list