[−][src]Struct dync::SliceCopyMut
Implementations
impl<'a, V> SliceCopyMut<'a, V>
[src]
pub fn from_slice<T: CopyElem>(slice: &'a mut [T]) -> SliceCopyMut<'a, V> where
V: VTable<T>,
[src]
V: VTable<T>,
Construct a SliceCopyMut
from a given typed slice by reusing the provided memory.
impl<'a, V: ?Sized> SliceCopyMut<'a, V>
[src]
pub fn into_raw_parts(
self
) -> (&'a mut [MaybeUninit<u8>], usize, TypeId, VTableRef<'a, V>)
[src]
self
) -> (&'a mut [MaybeUninit<u8>], usize, TypeId, VTableRef<'a, V>)
Convert this collection into its raw components.
This function exists mainly to enable the into_dyn
macro until CoerceUnsized
is
stabilized.
pub unsafe fn from_raw_parts(
data: &'a mut [MaybeUninit<u8>],
element_size: usize,
element_type_id: TypeId,
vtable: impl Into<VTableRef<'a, V>>
) -> SliceCopyMut<'a, V>
[src]
data: &'a mut [MaybeUninit<u8>],
element_size: usize,
element_type_id: TypeId,
vtable: impl Into<VTableRef<'a, V>>
) -> SliceCopyMut<'a, V>
Construct a SliceCopy
from raw bytes and type metadata.
Safety
Almost exclusively the only inputs that are safe here are the ones returned by
into_raw_parts
.
This function should not be used other than in internal APIs. It exists to enable the
into_dyn
macro until CoerceUsize
is stabilized.
pub fn swap(&mut self, i: usize, j: usize)
[src]
Swap the values at the two given indices.
pub fn upcast<U: From<V>>(self) -> SliceCopyMut<'a, U> where
V: Clone,
[src]
V: Clone,
Upcast the SliceCopyMut
into a more general base SliceCopy
.
This function converts the underlying virtual function table into a subset of the existing
pub fn copy_from_slice<T: CopyElem>(&mut self, slice: &[T]) -> Option<&mut Self>
[src]
Copy data from a given slice into the current slice.
Panics
This function will panic if the given slice has as different size than current.
pub fn check<T: Any>(&mut self) -> Option<&mut Self>
[src]
Check if the current buffer contains elements of the specified type. Returns Some(self)
if the type matches and None
otherwise.
pub fn reborrow(&self) -> SliceCopy<V>
[src]
Construct a clone of the current slice with a reduced lifetime.
This is equivalent to calling subslice
with the entire range.
pub fn reborrow_mut(&mut self) -> SliceCopyMut<V>
[src]
Construct a clone of the current slice with a reduced lifetime.
This is equivalent to calling subslice_mut
with the entire range.
pub fn element_type_id(&self) -> TypeId
[src]
Get the TypeId
of data stored within this buffer.
pub fn len(&self) -> usize
[src]
Get the number of elements stored in this buffer.
pub fn is_empty(&self) -> bool
[src]
Check if there are any elements stored in this buffer.
pub fn iter_as<T: Any>(&mut self) -> Option<IterMut<T>>
[src]
Return an iterator to a slice representing typed data.
Returs None
if the given type T
doesn't match the internal.
Examples
use dync::SliceCopyMut; let mut vec = vec![1.0_f32, 23.0, 0.01, 42.0, 11.43]; let mut buf = SliceCopyMut::<()>::from(vec.as_mut_slice()); for val in buf.iter_as::<f32>().unwrap() { *val += 1.0_f32; }
pub fn append_copy_to_vec<'b, T: CopyElem>(
&self,
vec: &'b mut Vec<T>
) -> Option<&'b mut Vec<T>>
[src]
&self,
vec: &'b mut Vec<T>
) -> Option<&'b mut Vec<T>>
Append copied items from this buffer to a given Vec<T>
. Return the mutable reference
Some(vec)
if type matched the internal type and None
otherwise.
pub fn copy_into_vec<T: CopyElem>(self) -> Option<Vec<T>>
[src]
Copies contents of self
into the given Vec
.
pub fn as_slice<T: Any>(&mut self) -> Option<&mut [T]>
[src]
Convert this SliceCopyMut
into a typed slice.
Returs None
if the given type T
doesn't match the internal.
pub fn get_as<T: CopyElem>(&mut self, i: usize) -> Option<&mut T>
[src]
Get i
'th element of the buffer.
pub fn rotate_left(&mut self, mid: usize)
[src]
Rotates the slice in-place such that the first mid
elements of the slice move to the end
while the last self.len() - mid
elements move to the front. After calling rotate_left
,
the element previously at index mid
will become the first element in the slice.
Example
use dync::*; let mut vec = vec![1u32,2,3,4,5]; let mut buf = SliceCopyMut::<()>::from_slice(vec.as_mut_slice()); buf.rotate_left(3); assert_eq!(buf.as_slice::<u32>().unwrap(), &[4,5,1,2,3]);
pub fn rotate_right(&mut self, k: usize)
[src]
Rotates the slice in-place such that the first self.len() - k
elements of the slice move
to the end while the last k
elements move to the front. After calling rotate_right
, the
element previously at index k
will become the first element in the slice.
Example
use dync::*; let mut vec = vec![1u32,2,3,4,5]; let mut buf = SliceCopyMut::<()>::from_slice(vec.as_mut_slice()); buf.rotate_right(3); assert_eq!(buf.as_slice::<u32>().unwrap(), &[3,4,5,1,2]);
pub fn iter(&mut self) -> impl Iterator<Item = CopyValueMut<V>>
[src]
Return an iterator over untyped value references stored in this slice.
In contrast to iter_as
, this function defers downcasting on a per element basis.
As a result, this type of iteration is typically less efficient if a typed value is needed
for each element.
pub fn chunks_exact(
&self,
chunk_size: usize
) -> impl Iterator<Item = SliceCopy<V>>
[src]
&self,
chunk_size: usize
) -> impl Iterator<Item = SliceCopy<V>>
pub fn chunks_exact_mut(
&mut self,
chunk_size: usize
) -> impl Iterator<Item = SliceCopyMut<V>>
[src]
&mut self,
chunk_size: usize
) -> impl Iterator<Item = SliceCopyMut<V>>
pub fn split_at(&mut self, mid: usize) -> (SliceCopyMut<V>, SliceCopyMut<V>)
[src]
pub fn get(&self, i: usize) -> CopyValueRef<V>
[src]
Get a immutable value reference to the element at index i
.
pub fn get_mut(&mut self, i: usize) -> CopyValueMut<V>
[src]
Get a mutable value reference to the element at index i
.
pub fn subslice<I>(&self, i: I) -> SliceCopy<V> where
I: SliceIndex<[MaybeUninit<u8>], Output = [MaybeUninit<u8>]> + ScaleRange,
[src]
I: SliceIndex<[MaybeUninit<u8>], Output = [MaybeUninit<u8>]> + ScaleRange,
Get an immutable subslice representing the given range of indices.
pub fn subslice_mut<I>(&mut self, i: I) -> SliceCopyMut<V> where
I: SliceIndex<[MaybeUninit<u8>], Output = [MaybeUninit<u8>]> + ScaleRange,
[src]
I: SliceIndex<[MaybeUninit<u8>], Output = [MaybeUninit<u8>]> + ScaleRange,
Get a mutable subslice representing the given range of indices.
pub fn into_subslice<I>(self, i: I) -> SliceCopyMut<'a, V> where
I: SliceIndex<[MaybeUninit<u8>], Output = [MaybeUninit<u8>]> + ScaleRange,
[src]
I: SliceIndex<[MaybeUninit<u8>], Output = [MaybeUninit<u8>]> + ScaleRange,
Conver this slice into a mutable subslice representing the given range of indices.
Trait Implementations
impl<'a, T, V> From<&'a mut [T]> for SliceCopyMut<'a, V> where
T: CopyElem,
V: VTable<T>,
[src]
T: CopyElem,
V: VTable<T>,
Convert a &mut [T]
to a SliceCopyMut
.
fn from(s: &'a mut [T]) -> SliceCopyMut<'a, V>
[src]
impl<'b, 'a: 'b, V: ?Sized> From<&'b SliceCopyMut<'a, V>> for SliceCopy<'b, V>
[src]
fn from(s: &'b SliceCopyMut<'a, V>) -> SliceCopy<'b, V>
[src]
impl<'a, V> From<SliceCopyMut<'a, V>> for Meta<VTableRef<'a, V>>
[src]
fn from(slice: SliceCopyMut<'a, V>) -> Self
[src]
impl<'a, V: Clone> From<SliceCopyMut<'a, V>> for Meta<Ptr<V>>
[src]
fn from(slice: SliceCopyMut<'a, V>) -> Self
[src]
impl<'a, V: ?Sized> From<SliceCopyMut<'a, V>> for SliceCopy<'a, V>
[src]
fn from(s: SliceCopyMut<'a, V>) -> SliceCopy<'a, V>
[src]
Auto Trait Implementations
impl<'a, V: ?Sized> RefUnwindSafe for SliceCopyMut<'a, V> where
V: RefUnwindSafe,
V: RefUnwindSafe,
impl<'a, V: ?Sized> Send for SliceCopyMut<'a, V> where
V: Send + Sync,
V: Send + Sync,
impl<'a, V: ?Sized> Sync for SliceCopyMut<'a, V> where
V: Sync,
V: Sync,
impl<'a, V: ?Sized> Unpin for SliceCopyMut<'a, V>
impl<'a, V = ()> !UnwindSafe for SliceCopyMut<'a, V>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
[src]
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
fn as_any(&self) -> &(dyn Any + 'static)
[src]
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> DowncastSync for T where
T: Send + Sync + Any,
[src]
T: Send + Sync + Any,
impl<T> DropBytes for T where
T: 'static,
[src]
T: 'static,
unsafe fn drop_bytes(&mut [MaybeUninit<u8>])
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,