Re: [rust-dev] Vectors, mutability & vec::dedup

2012-12-17 Thread Tom Lee
Alright, brace yourself for more stupid questions, Graydon. :) On Thu, Dec 13, 2012 at 10:52 AM, Graydon Hoare wrote: > On 12-12-13 12:17 AM, Tom Lee wrote: > > > It looks like the 'move' operations here are directly modifying the > > contents of the vector by moving data around in the vector. T

Re: [rust-dev] Reading shared immutable data

2012-12-17 Thread Patrick Walton
On 12/17/12 6:27 PM, Michael Neumann wrote: Am 18.12.2012 03:11, schrieb Patrick Walton: * Use unsafe code by casting to an unsafe pointer and sending the unsafe pointer over a channel; do this only as a last resort. But don't I get into problems with GC when I do that? So I create the data st

Re: [rust-dev] Reading shared immutable data

2012-12-17 Thread Michael Neumann
Am 18.12.2012 03:11, schrieb Patrick Walton: On 12/17/12 6:03 PM, Michael Neumann wrote: Hi, We have a very huge immutable data structure that we want to share (read-only) between many light-weight threads. From what I have seen, I should use Arc. Is there any other way to share the data betwe

Re: [rust-dev] Reading shared immutable data

2012-12-17 Thread Patrick Walton
On 12/17/12 6:03 PM, Michael Neumann wrote: Hi, We have a very huge immutable data structure that we want to share (read-only) between many light-weight threads. From what I have seen, I should use Arc. Is there any other way to share the data between threads? You can also: * Use a reader-wr

[rust-dev] Reading shared immutable data

2012-12-17 Thread Michael Neumann
Hi, We have a very huge immutable data structure that we want to share (read-only) between many light-weight threads. From what I have seen, I should use Arc. Is there any other way to share the data between threads? And when using Arc, can I access the data in parallel by all threads? Best r

Re: [rust-dev] purely function red-black tree

2012-12-17 Thread Erick Tryzelaar
Is it important for `traverse` to pass along an option type? Is it important to inform end users that a key has been deleted? Or is that implementation specific? If so, I suggest rewriting `traverse` to something like this (assuming this actually works): impl RBMap: iter::BaseIter<(&K, &V)> {

Re: [rust-dev] purely function red-black tree

2012-12-17 Thread Graydon Hoare
On 12-12-17 11:28 AM, Graydon Hoare wrote: > On 12-12-14 03:51 PM, Steve Jenson 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 >> >>

Re: [rust-dev] purely function red-black tree

2012-12-17 Thread Graydon Hoare
On 12-12-14 03:51 PM, Steve Jenson 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

Re: [rust-dev] simple hash map for storing structs that contain ~str and/or ~[]

2012-12-17 Thread Tim Taubert
On 12/17/2012 04:42 PM, Patrick Walton wrote: > Try returning a reference from find() instead. It's warning you that > find() is copying out the data (since it returns V and not &V). I read up on borrowed pointers and made find() return &self/V. After turning this: impl LinearMap: Map { into thi

Re: [rust-dev] simple hash map for storing structs that contain ~str and/or ~[]

2012-12-17 Thread Tim Taubert
On 12/17/2012 04:42 PM, Patrick Walton wrote: > On 12/17/12 6:42 AM, Tim Taubert wrote: >> Is there anything I can do about this other than using managed boxes? I >> really don't want to force people to use GC. > > Try returning a reference from find() instead. It's warning you that > find() is co

Re: [rust-dev] simple hash map for storing structs that contain ~str and/or ~[]

2012-12-17 Thread Patrick Walton
On 12/17/12 6:42 AM, Tim Taubert wrote: Is there anything I can do about this other than using managed boxes? I really don't want to force people to use GC. Try returning a reference from find() instead. It's warning you that find() is copying out the data (since it returns V and not &V). In

[rust-dev] simple hash map for storing structs that contain ~str and/or ~[]

2012-12-17 Thread Tim Taubert
I'm trying to create simple hash map with an interface like this: trait Map { fn find(&const self, k: &K) -> Option; fn insert(&mut self, k: K, +v: V); fn remove(&mut self, k: &K); } The implementation itself is subject to change and I'll experiment with that a bit. I copied some of the par