1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
use crate::{AsSoaRef, SoaArray, SoaDeref, SoaRaw};
/// Provides [`Soa`] compatibility.
///
/// # Safety
///
/// [`Soapy::Deref`] mut be `#[repr(transparent)]` with [`Slice<Self::Raw>`].
/// This trait should be derived using the derive macro.
///
/// [`Slice<Self::Raw>`]: crate::Slice
/// [`Soa`]: crate::Soa
pub unsafe trait Soapy: AsSoaRef<Item = Self> {
/// Implements internal, unsafe, low-level routines used by [`Soa`]
///
/// [`Soa`]: crate::Soa
type Raw: SoaRaw<Item = Self>;
/// [`Slice`] dereferences to this type to provide getters for the individual
/// fields as slices.
///
/// [`Slice`]: crate::Slice
type Deref: ?Sized + SoaDeref<Item = Self>;
/// A reference to an element of a [`Slice`].
///
/// For each field with type `T`, this type has a field with type `&T`.
///
/// [`Slice`]: crate::Slice
type Ref<'a>: Copy + Clone + AsSoaRef<Item = Self>
where
Self: 'a;
/// A reference to an element of a [`Slice`].
///
/// For each field with type `T`, this type has a field with type `&mut T`.
///
/// [`Slice`]: crate::Slice
type RefMut<'a>: AsSoaRef<Item = Self>
where
Self: 'a;
/// The SoA array type.
///
/// For each field with type `T`, this type has a field with type `[T; N]`.
type Array<const N: usize>: SoaArray<Item = Self>;
/// The slices that make up a [`Slice`].
///
/// For each field with type `T`, this type has a field with type `&[T]`.
///
/// [`Slice`]: crate::Slice
type Slices<'a>
where
Self: 'a;
/// The mutable slices that make up a [`Slice`].
///
/// For each field with type `T`, this type has a field with type `&mut [T]`.
///
/// [`Slice`]: crate::Slice
type SlicesMut<'a>
where
Self: 'a;
}