Get a reference to the data if the type matches.
(&self)
| 38 | |
| 39 | /// Get a reference to the data if the type matches. |
| 40 | pub fn get<T: Any + 'static>(&self) -> Option<&T> { |
| 41 | if self.type_id == TypeId::of::<T>() { |
| 42 | self.data.downcast_ref() |
| 43 | } else { |
| 44 | None |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | /// Get a mutable reference to the data if the type matches. |
| 49 | pub fn get_mut<T: Any + 'static>(&mut self) -> Option<&mut T> { |
no test coverage detected