@@ -66,7 +66,7 @@ impl TypeMap {
66
66
self . data . remove ( & TypeId :: of :: < K > ( ) )
67
67
}
68
68
69
- /// Gets the given key's corresponding entry in the map for in-place manipulation.
69
+ /// Get the given key's corresponding entry in the map for in-place manipulation.
70
70
pub fn entry < ' a , K : Assoc < V > , V : ' static > ( & ' a mut self ) -> Entry < ' a , K , V > {
71
71
match self . data . entry ( TypeId :: of :: < K > ( ) ) {
72
72
hashmap:: Occupied ( e) => Occupied ( OccupiedEntry { data : e } ) ,
@@ -79,22 +79,32 @@ impl TypeMap {
79
79
80
80
/// Get a mutable reference to the underlying HashMap
81
81
pub unsafe fn data_mut ( & mut self ) -> & mut HashMap < TypeId , Box < Any + ' static > > { & mut self . data }
82
+
83
+ /// Get the number of values stored in the map.
84
+ pub fn len ( & self ) -> uint {
85
+ self . data . len ( )
86
+ }
87
+
88
+ /// Remove all entries from the map.
89
+ pub fn clear ( & mut self ) {
90
+ self . data . clear ( )
91
+ }
82
92
}
83
93
84
- /// A view onto an entry in the map .
94
+ /// A view onto an entry in a TypeMap .
85
95
pub enum Entry < ' a , K , V > {
86
- /// A view onto an occupied entry in the map .
96
+ /// A view onto an occupied entry in a TypeMap .
87
97
Occupied ( OccupiedEntry < ' a , K , V > ) ,
88
- /// A view onto an unoccupied entry in the map .
98
+ /// A view onto an unoccupied entry in a TypeMap .
89
99
Vacant ( VacantEntry < ' a , K , V > )
90
100
}
91
101
92
- /// A view onto an occupied entry in the map .
102
+ /// A view onto an occupied entry in a TypeMap .
93
103
pub struct OccupiedEntry < ' a , K , V > {
94
104
data : hashmap:: OccupiedEntry < ' a , TypeId , Box < Any + ' static > >
95
105
}
96
106
97
- /// A view onto an unoccupied entry in the map .
107
+ /// A view onto an unoccupied entry in a TypeMap .
98
108
pub struct VacantEntry < ' a , K , V > {
99
109
data : hashmap:: VacantEntry < ' a , TypeId , Box < Any + ' static > >
100
110
}
@@ -145,18 +155,6 @@ impl<'a, K, V: 'static> VacantEntry<'a, K, V> {
145
155
}
146
156
}
147
157
148
- impl Collection for TypeMap {
149
- fn len ( & self ) -> uint {
150
- self . data . len ( )
151
- }
152
- }
153
-
154
- impl Mutable for TypeMap {
155
- fn clear ( & mut self ) {
156
- self . data . clear ( )
157
- }
158
- }
159
-
160
158
#[ cfg( test) ]
161
159
mod test {
162
160
use super :: { TypeMap , Assoc , Occupied , Vacant } ;
0 commit comments