@@ -3,35 +3,35 @@ use std::boxed::BoxAny;
3
3
use std:: collections:: HashMap ;
4
4
5
5
pub struct TypeMap {
6
- data : HashMap < TypeId , Box < Any + ' static > >
6
+ data : HashMap < TypeId , Box < Any > >
7
7
}
8
8
9
9
impl TypeMap {
10
10
pub fn new ( ) -> TypeMap {
11
11
TypeMap { data : HashMap :: new ( ) }
12
12
}
13
13
14
- pub fn find < T : ' static > ( & self ) -> Option < & T > {
14
+ pub fn find < T : Any > ( & self ) -> Option < & T > {
15
15
self . data . get ( & TypeId :: of :: < T > ( ) ) . and_then ( |a| a. downcast_ref ( ) )
16
16
}
17
17
18
- pub fn find_mut < T : ' static > ( & mut self ) -> Option < & mut T > {
18
+ pub fn find_mut < T : Any > ( & mut self ) -> Option < & mut T > {
19
19
self . data . get_mut ( & TypeId :: of :: < T > ( ) ) . and_then ( |a| a. downcast_mut ( ) )
20
20
}
21
21
22
- pub fn insert < T : ' static > ( & mut self , val : T ) -> bool {
22
+ pub fn insert < T : Any > ( & mut self , val : T ) -> bool {
23
23
self . data . insert ( TypeId :: of :: < T > ( ) , Box :: new ( val) as Box < Any > ) . is_none ( )
24
24
}
25
25
26
- pub fn remove < T : ' static > ( & mut self ) -> bool {
26
+ pub fn remove < T : Any > ( & mut self ) -> bool {
27
27
self . data . remove ( & TypeId :: of :: < T > ( ) ) . is_some ( )
28
28
}
29
29
30
- pub fn contains < T : ' static > ( & self ) -> bool {
30
+ pub fn contains < T : Any > ( & self ) -> bool {
31
31
self . data . contains_key ( & TypeId :: of :: < T > ( ) )
32
32
}
33
33
34
- pub fn pop < T : ' static > ( & mut self ) -> Option < T > {
34
+ pub fn pop < T : Any > ( & mut self ) -> Option < T > {
35
35
let data = match self . data . remove ( & TypeId :: of :: < T > ( ) ) {
36
36
Some ( data) => data,
37
37
None => return None ,
0 commit comments