I'm trying to create simple hash map with an interface like this:
trait Map<K:Eq Hash, V> {
fn find(&const self, k: &K) -> Option<V>;
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 parts from send_map and tried the
following:
struct Item {
v: uint
}
fn test() {
let item = Item {v: 0};
let mut map = LinearMap::new();
map.insert(~"foo", item);
assert map.find(&~"foo") == Some(item);
}
This works fine until I try to store structs that contain a ~str or ~[].
I'm getting this error:
warning: instantiating copy type parameter with a not implicitly
copyable type
assert map.find(&~"foo") == None;
Is there anything I can do about this other than using managed boxes? I
really don't want to force people to use GC.
Thanks,
- Tim
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev