@@ -3,9 +3,7 @@ use std::collections::HashMap;
3
3
use std:: hash:: { BuildHasherDefault , Hasher } ;
4
4
use std:: fmt;
5
5
6
- // `Box<Any>` is now `Box<dyn Any>`, but we can't change yet (minimum Rust)
7
- #[ allow( warnings) ]
8
- type AnyMap = HashMap < TypeId , Box < Any + Send + Sync > , BuildHasherDefault < IdHasher > > ;
6
+ type AnyMap = HashMap < TypeId , Box < dyn Any + Send + Sync > , BuildHasherDefault < IdHasher > > ;
9
7
10
8
// With TypeIds as keys, there's no need to hash them. They are already hashes
11
9
// themselves, coming from the compiler. The IdHasher just holds the u64 of
@@ -71,13 +69,10 @@ impl Extensions {
71
69
. get_or_insert_with ( || Box :: new ( HashMap :: default ( ) ) )
72
70
. insert ( TypeId :: of :: < T > ( ) , Box :: new ( val) )
73
71
. and_then ( |boxed| {
74
- #[ allow( warnings) ]
75
- {
76
- ( boxed as Box < Any + ' static > )
72
+ ( boxed as Box < dyn Any + ' static > )
77
73
. downcast ( )
78
74
. ok ( )
79
75
. map ( |boxed| * boxed)
80
- }
81
76
} )
82
77
}
83
78
@@ -98,12 +93,7 @@ impl Extensions {
98
93
. map
99
94
. as_ref ( )
100
95
. and_then ( |map| map. get ( & TypeId :: of :: < T > ( ) ) )
101
- . and_then ( |boxed| {
102
- #[ allow( warnings) ]
103
- {
104
- ( & * * boxed as & ( Any + ' static ) ) . downcast_ref ( )
105
- }
106
- } )
96
+ . and_then ( |boxed| ( & * * boxed as & ( dyn Any + ' static ) ) . downcast_ref ( ) )
107
97
}
108
98
109
99
/// Get a mutable reference to a type previously inserted on this `Extensions`.
@@ -123,12 +113,7 @@ impl Extensions {
123
113
. map
124
114
. as_mut ( )
125
115
. and_then ( |map| map. get_mut ( & TypeId :: of :: < T > ( ) ) )
126
- . and_then ( |boxed| {
127
- #[ allow( warnings) ]
128
- {
129
- ( & mut * * boxed as & mut ( Any + ' static ) ) . downcast_mut ( )
130
- }
131
- } )
116
+ . and_then ( |boxed| ( & mut * * boxed as & mut ( dyn Any + ' static ) ) . downcast_mut ( ) )
132
117
}
133
118
134
119
@@ -151,13 +136,10 @@ impl Extensions {
151
136
. as_mut ( )
152
137
. and_then ( |map| map. remove ( & TypeId :: of :: < T > ( ) ) )
153
138
. and_then ( |boxed| {
154
- #[ allow( warnings) ]
155
- {
156
- ( boxed as Box < Any + ' static > )
139
+ ( boxed as Box < dyn Any + ' static > )
157
140
. downcast ( )
158
141
. ok ( )
159
142
. map ( |boxed| * boxed)
160
- }
161
143
} )
162
144
}
163
145
0 commit comments