extendr_api::prelude::utils::slice

Struct SliceGroup

pub struct SliceGroup<'a, E, T = <E as Entity>::Unit>(<<E as Entity>::Group as ForCopyType>::FaerOfCopy<*const [T]>, PhantomData<&'a ()>)
where
    E: Entity,
    T: 'a;
Expand description

Analogous to an immutable reference to a slice for groups.

Tuple Fields§

§0: <<E as Entity>::Group as ForCopyType>::FaerOfCopy<*const [T]>§1: PhantomData<&'a ()>

Implementations§

§

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

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

Create a new SliceGroup from a group of slice references.

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

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

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

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

§

impl<'a, E> SliceGroup<'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().

§

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

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>) -> SliceGroup<'a, E, T>

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

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

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

pub unsafe fn subslice_unchecked( self, range: Range<usize>, ) -> SliceGroup<'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_ref_iter(self) -> impl Iterator<Item = RefGroup<'a, E, T>>

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

pub fn into_chunks_exact( self, chunk_size: usize, ) -> (impl Iterator<Item = SliceGroup<'a, E, T>>, SliceGroup<'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> Clone for SliceGroup<'_, E, T>
where E: Entity,

§

fn clone(&self) -> SliceGroup<'_, E, T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<E, T> Debug for SliceGroup<'_, 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 SliceGroup<'a, E, T>
where E: Entity,

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<E, T> Copy for SliceGroup<'_, E, T>
where E: Entity,

§

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

§

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

Auto Trait Implementations§

§

impl<'a, E, T> Freeze for SliceGroup<'a, E, T>
where <<E as Entity>::Group as ForCopyType>::FaerOfCopy<*const [T]>: Freeze,

§

impl<'a, E, T> RefUnwindSafe for SliceGroup<'a, E, T>
where <<E as Entity>::Group as ForCopyType>::FaerOfCopy<*const [T]>: RefUnwindSafe,

§

impl<'a, E, T> Unpin for SliceGroup<'a, E, T>
where <<E as Entity>::Group as ForCopyType>::FaerOfCopy<*const [T]>: Unpin,

§

impl<'a, E, T> UnwindSafe for SliceGroup<'a, E, T>
where <<E as Entity>::Group as ForCopyType>::FaerOfCopy<*const [T]>: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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>,