#![warn(missing_docs, clippy::missing_safety_doc)]
use core::ops::Deref;
use super::GenericVector;
#[repr(transparent)]
pub struct StreamingVector<'a, V: GenericVector>(pub(crate) &'a V);
impl<V: GenericVector> Clone for StreamingVector<'_, V> {
fn clone(&self) -> Self {
*self
}
}
impl<V: GenericVector> Copy for StreamingVector<'_, V> {}
#[repr(transparent)]
pub struct StreamingVectorMut<'a, V: GenericVector>(pub(crate) &'a mut V);
impl<'a, V: GenericVector> Deref for StreamingVectorMut<'a, V> {
type Target = StreamingVector<'a, V>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
unsafe { core::mem::transmute(self) }
}
}
impl<V: GenericVector> StreamingVector<'_, V> {
#[inline(always)]
pub fn load(&self) -> V {
unsafe { V::load_streaming(self.0 as *const _ as *const V::Element) }
}
#[inline(always)]
pub fn load_cached(&self) -> V {
unsafe { V::load(self.0 as *const _ as *const V::Element) }
}
}
impl<V: GenericVector> StreamingVectorMut<'_, V> {
#[inline(always)]
pub fn store(&mut self, vec: V) {
unsafe { vec.store_streaming(self.0 as *mut _ as *mut V::Element) }
}
#[inline(always)]
pub fn store_cached(&mut self, vec: V) {
unsafe { vec.store(self.0 as *mut _ as *mut V::Element) }
}
}