This was necessary in the days of the raw module, when inserting to the
raw map was the unsafe operation rather than getting mutable access to
the raw map, to which I have changed it now.
/// Otherwise, `None` is returned.
#[inline]
pub fn insert<T: IntoBox<A>>(&mut self, value: T) -> Option<T> {
- unsafe {
- self.raw.insert(TypeId::of::<T>(), value.into_box())
- .map(|any| *any.downcast_unchecked::<T>())
- }
+ self.raw.insert(TypeId::of::<T>(), value.into_box())
+ .map(|any| unsafe { *any.downcast_unchecked::<T>() })
}
// rustc 1.60.0-nightly has another method try_insert that would be nice to add when stable.