Skip to content

Commit 9105cb6

Browse files
committed
revise map interface so that K need not be copyable
1 parent fc9eadf commit 9105cb6

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/libstd/map.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type set<K> = hashmap<K, ()>;
2121

2222
type hashmap<K, V> = chained::t<K, V>;
2323

24-
iface map<K: copy, V: copy> {
24+
iface map<K, V: copy> {
2525
#[doc = "Return the number of elements in the map"]
2626
fn size() -> uint;
2727

@@ -33,7 +33,7 @@ iface map<K: copy, V: copy> {
3333
3434
Returns true if the key did not already exist in the map
3535
"]
36-
fn insert(K, V) -> bool;
36+
fn insert(+K, +V) -> bool;
3737

3838
#[doc = "Returns true if the map contains a value for the specified key"]
3939
fn contains_key(K) -> bool;
@@ -96,7 +96,7 @@ mod chained {
9696
found_after(@entry<K,V>, @entry<K,V>)
9797
}
9898

99-
impl private_methods<K: copy, V: copy> for t<K, V> {
99+
impl private_methods<K, V: copy> for t<K, V> {
100100
fn search_rem(k: K, h: uint, idx: uint,
101101
e_root: @entry<K,V>) -> search_result<K,V> {
102102
let mut e0 = e_root;
@@ -174,7 +174,7 @@ mod chained {
174174
}
175175
}
176176

177-
impl hashmap<K: copy, V: copy> of map<K, V> for t<K, V> {
177+
impl hashmap<K, V: copy> of map<K, V> for t<K, V> {
178178
fn size() -> uint { self.count }
179179

180180
fn contains_key(k: K) -> bool {
@@ -185,7 +185,7 @@ mod chained {
185185
}
186186
}
187187

188-
fn insert(k: K, v: V) -> bool {
188+
fn insert(+k: K, +v: V) -> bool {
189189
let hash = self.hasher(k);
190190
alt self.search_tbl(k, hash) {
191191
not_found {
@@ -249,7 +249,7 @@ mod chained {
249249

250250
fn each(blk: fn(K,V) -> bool) {
251251
for self.each_entry { |entry|
252-
if !blk(copy entry.key, copy entry.value) { break; }
252+
if !blk(entry.key, copy entry.value) { break; }
253253
}
254254
}
255255

src/libstd/smallintmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> {
6262
}
6363
sz
6464
}
65-
fn insert(&&key: uint, value: V) -> bool {
65+
fn insert(+key: uint, +value: V) -> bool {
6666
let exists = contains_key(self, key);
6767
insert(self, key, value);
6868
ret !exists;

src/test/run-pass/class-impl-parameterized-iface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class cat implements map<int, bool> {
3636
}
3737

3838
fn size() -> uint { self.meows as uint }
39-
fn insert(&&k: int, &&v: bool) -> bool {
39+
fn insert(+k: int, +v: bool) -> bool {
4040
if v { self.meows += k; } else { self.meows -= k; };
4141
true
4242
}

src/test/run-pass/class-impl-very-parameterized-iface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class cat<T: copy> implements map<int, T> {
4141
}
4242

4343
fn size() -> uint { self.meows as uint }
44-
fn insert(&&k: int, &&_v: T) -> bool {
44+
fn insert(+k: int, +_v: T) -> bool {
4545
self.meows += k;
4646
true
4747
}

0 commit comments

Comments
 (0)