Merge pull request #4 from tomassedovic/impl-mutable
Implement Collection and Mutable traits
This commit is contained in:
commit
8134113fa9
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