Chris Morgan
›
Git
›
anymap
› blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
commit
grep
author
committer
pickaxe
?
search:
re
Enabled Cargo and moved Makefile to use target.
[anymap]
/
src
/
lib.rs
diff --git
a/src/lib.rs
b/src/lib.rs
index d0bce3c4ec02962e204261d4c6ee6c0140fb1456..b67731966952329e32591fc45b1dee86797440f1 100644
(file)
--- a/
src/lib.rs
+++ b/
src/lib.rs
@@
-13,7
+13,7
@@
extern crate test;
use std::any::Any;
use std::intrinsics::TypeId;
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;
use std::hash::{Hash, Hasher, Writer};
use std::mem::{transmute, transmute_copy};
use std::raw::TraitObject;
@@
-109,7
+109,7
@@
impl<'a> UncheckedAnyMutRefExt<'a> for &'a mut Any {
///
/// Values containing non-static references are not permitted.
pub struct AnyMap {
///
/// Values containing non-static references are not permitted.
pub struct AnyMap {
- data: HashMap<TypeId, Box<Any>
:'static
, TypeIdHasher>,
+ data: HashMap<TypeId, Box<Any>, TypeIdHasher>,
}
impl AnyMap {
}
impl AnyMap {
@@
-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(|| {
#[bench]
fn bench_insertion(b: &mut ::test::Bencher) {
b.iter(|| {