Merge pull request #4 from tomassedovic/impl-mutable

Implement Collection and Mutable traits
This commit is contained in:
Chris Morgan 2014-06-23 22:27:50 +10:00
commit 8134113fa9

View file

@ -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(|| {