message: add type_id for anyarray
diff: use ndarray::{Array, ArrayView, ArrayViewMut, Axis, Dimension, Ix, NdIndex};
  -use std::any::Any;
  +use std::any::{Any, TypeId};
  use std::mem::transmute;
  pub trait AnyArray<D>: Send {
  @@ -19,6 +19,17 @@ pub trait AnyArrayView<'a, D>: Send {
  Box<dyn AnyArrayView<'a, D> + 'a>,
  );
  unsafe fn uget(&self, index: (usize, usize)) -> &();
  + fn type_id(&self) -> TypeId;
  +}
  +
  +impl<'a, D> dyn AnyArrayView<'a, D> {
  + pub fn uget_checked<A: 'static>(&self, index: (usize, usize)) -> Option<&'a A> {
  + if self.type_id() == TypeId::of::<A>() {
  + Some(unsafe { transmute(self.uget(index)) })
  + } else {
  + None
  + }
  + }
  }
  pub trait AnyArrayViewMut<'a, D>: Send {
  @@ -32,6 +43,17 @@ pub trait AnyArrayViewMut<'a, D>: Send {
  Box<dyn AnyArrayViewMut<'a, D> + 'a>,
  );
  unsafe fn uget_mut(&mut self, index: (usize, usize)) -> &mut ();
  + fn type_id(&self) -> TypeId;
  +}
  +
  +impl<'a, D> dyn AnyArrayViewMut<'a, D> + 'a {
  + pub fn uget_mut_checked<A: 'static>(&mut self, index: (usize, usize)) -> Option<&'a mut A> {
  + if AnyArrayViewMut::<'a, D>::type_id(self) == TypeId::of::<A>() {
  + Some(unsafe { transmute(self.uget_mut(index)) })
  + } else {
  + None
  + }
  + }
  }
  impl<A, D> AnyArray<D> for Array<A, D>
  @@ -55,7 +77,7 @@ where
  impl<'a, A, D> AnyArrayView<'a, D> for ArrayView<'a, A, D>
  where
  - A: Send + Sync,
  + A: Send + Sync + 'static,
  D: Dimension + 'static,
  (usize, usize): NdIndex<D>,
  {
  @@ -74,11 +96,15 @@ where
  unsafe fn uget(&self, index: (usize, usize)) -> &() {
  transmute(self.uget(index))
  }
  +
  + fn type_id(&self) -> TypeId {
  + TypeId::of::<A>()
  + }
  }
  impl<'a, A, D> AnyArrayViewMut<'a, D> for ArrayViewMut<'a, A, D>
  where
  - A: Send,
  + A: Send + 'static,
  D: Dimension + 'static,
  (usize, usize): NdIndex<D>,
  {
  @@ -93,7 +119,12 @@ where
  let (l, r) = ArrayViewMut::<A, D>::split_at(*self, axis, index);
  (Box::new(l), Box::new(r))
  }
  +
  unsafe fn uget_mut(&mut self, index: (usize, usize)) -> &mut () {
  transmute(self.uget_mut(index))
  }
  +
  + fn type_id(&self) -> TypeId {
  + TypeId::of::<A>()
  + }
  }
  