There's no need for unsafe
; trait Any
provides downcast_ref
to encapsulate the pattern.
pub fn get<T: 'static>(&self) -> Option<&T> {
let x: &dyn Any = match self {
Self::A(x) => x,
Self::B(x) => x,
Self::C(x) => x,
};
x.downcast_ref()
}