extendr_api::prelude::utils::slice

Struct SliceGroupMut

pub struct SliceGroupMut<'a, E, T = <E as Entity>::Unit>(<<E as Entity>::Group as ForType>::FaerOf<*mut [T]>, PhantomData<&'a mut ()>)
where
    E: Entity,
    T: 'a;
Expand description

Analogous to a mutable reference to a slice for groups.

Tuple Fields§

§0: <<E as Entity>::Group as ForType>::FaerOf<*mut [T]>§1: PhantomData<&'a mut ()>

Implementations§

§

impl<'a, E, T> SliceGroupMut<'a, E, T>
where E: Entity,

pub fn new( slice: <<E as Entity>::Group as ForType>::FaerOf<&'a mut [T]>, ) -> SliceGroupMut<'a, E, T>

Create a new SliceGroup from a group of mutable slice references.

pub fn into_inner( self, ) -> <<E as Entity>::Group as ForType>::FaerOf<&'a mut [T]>

Consume self to return the internally stored group of mutable slice references.

pub fn as_arrays_mut<const N: usize>( self, ) -> (SliceGroupMut<'a, E, [T; N]>, SliceGroupMut<'a, E, T>)

Decompose self into a mutable slice of arrays of size N, and a remainder part with length < N.

§

impl<'a, E> SliceGroupMut<'a, E>
where E: Entity,

pub fn read(&self, idx: usize) -> E

Read the element at position idx.

pub unsafe fn read_unchecked(&self, idx: usize) -> E

Read the element at position idx, without bound checks.

§Safety

The behavior is undefined if idx >= self.len().

pub fn write(&mut self, idx: usize, value: E)

Write value to the location at position idx.

pub unsafe fn write_unchecked(&mut self, idx: usize, value: E)

Write value to the location at position idx, without bound checks.

§Safety

The behavior is undefined if idx >= self.len().

pub fn fill_zero(&mut self)

Fill the slice with zeros.

§

impl<'a, E, T> SliceGroupMut<'a, E, T>
where E: Entity,

pub fn get_mut(self, idx: usize) -> RefGroupMut<'a, E, T>

Get a RefGroupMut pointing to the element at position idx.

pub unsafe fn get_unchecked_mut(self, idx: usize) -> RefGroupMut<'a, E, T>

Get a RefGroupMut pointing to the element at position idx.

§Safety

The behavior is undefined if idx >= self.len().

pub fn get(self, idx: usize) -> RefGroup<'a, E, T>

Get a RefGroup pointing to the element at position idx.

pub unsafe fn get_unchecked(self, idx: usize) -> RefGroup<'a, E, T>

Get a RefGroup pointing to the element at position idx, without bound checks.

§Safety

The behavior is undefined if idx >= self.len().

pub fn is_empty(&self) -> bool

Checks whether the slice is empty.

pub fn len(&self) -> usize

Returns the length of the slice.

pub fn subslice(self, range: Range<usize>) -> SliceGroupMut<'a, E, T>

Returns the subslice of self from the start to the end of the provided range.

pub unsafe fn subslice_unchecked( self, range: Range<usize>, ) -> SliceGroupMut<'a, E, T>

Returns the subslice of self from the start to the end of the provided range, without bound checks.

§Safety

The behavior is undefined if range.start > range.end or range.end > self.len().

pub fn into_mut_iter(self) -> impl Iterator<Item = RefGroupMut<'a, E, T>>

Returns an iterator of RefGroupMut over the elements of the slice.

pub fn split_at( self, idx: usize, ) -> (SliceGroupMut<'a, E, T>, SliceGroupMut<'a, E, T>)

Split self at the midpoint idx, and return the two parts.

pub fn into_chunks_exact( self, chunk_size: usize, ) -> (impl Iterator<Item = SliceGroupMut<'a, E, T>>, SliceGroupMut<'a, E, T>)

Returns an iterator of slices over chunks of size chunk_size, and the remainder of the slice.

Trait Implementations§

§

impl<E, T> Debug for SliceGroupMut<'_, E, T>
where E: Entity, T: Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<'a, E, T> IntoConst for SliceGroupMut<'a, E, T>
where E: Entity,

§

type Target = SliceGroup<'a, E, T>

§

fn into_const(self) -> <SliceGroupMut<'a, E, T> as IntoConst>::Target

§

impl<'short, 'a, E, T> Reborrow<'short> for SliceGroupMut<'a, E, T>
where E: Entity,

§

type Target = SliceGroup<'short, E, T>

§

fn rb(&'short self) -> <SliceGroupMut<'a, E, T> as Reborrow<'short>>::Target

§

impl<'short, 'a, E, T> ReborrowMut<'short> for SliceGroupMut<'a, E, T>
where E: Entity,

§

type Target = SliceGroupMut<'short, E, T>

§

fn rb_mut( &'short mut self, ) -> <SliceGroupMut<'a, E, T> as ReborrowMut<'short>>::Target

§

impl<E, T> Send for SliceGroupMut<'_, E, T>
where E: Entity, T: Send,

§

impl<E, T> Sync for SliceGroupMut<'_, E, T>
where E: Entity, T: Sync,

Auto Trait Implementations§

§

impl<'a, E, T> Freeze for SliceGroupMut<'a, E, T>
where <<E as Entity>::Group as ForType>::FaerOf<*mut [T]>: Freeze,

§

impl<'a, E, T> RefUnwindSafe for SliceGroupMut<'a, E, T>
where <<E as Entity>::Group as ForType>::FaerOf<*mut [T]>: RefUnwindSafe,

§

impl<'a, E, T> Unpin for SliceGroupMut<'a, E, T>
where <<E as Entity>::Group as ForType>::FaerOf<*mut [T]>: Unpin,

§

impl<'a, E, T = <E as Entity>::Unit> !UnwindSafe for SliceGroupMut<'a, E, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> UniversalReborrow for T
where T: for<'a> Reborrow<'a>,

§

impl<T> UniversalReborrowMut for T
where T: for<'a> ReborrowMut<'a>,