Implement Collection and Mutable traits
These just proxy the calls to the underlying hashmap.
This commit is contained in:
parent
da3b57feb8
commit
a9b1e31b70
18
src/lib.rs
18
src/lib.rs
|
@ -13,7 +13,7 @@ extern crate test;
|
|||
|
||||
use std::any::Any;
|
||||
use std::intrinsics::TypeId;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{Collection, HashMap, Mutable};
|
||||
use std::hash::{Hash, Hasher, Writer};
|
||||
use std::mem::{transmute, transmute_copy};
|
||||
use std::raw::TraitObject;
|
||||
|
@ -144,6 +144,22 @@ impl AnyMap {
|
|||
}
|
||||
}
|
||||
|
||||
impl Collection for AnyMap {
|
||||
fn len(&self) -> uint {
|
||||
self.data.len()
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
self.data.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
impl Mutable for AnyMap {
|
||||
fn clear(&mut self) {
|
||||
self.data.clear();
|
||||
}
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_insertion(b: &mut ::test::Bencher) {
|
||||
b.iter(|| {
|
||||
|
|
Loading…
Reference in a new issue