[−][src]Struct dync::SliceDrop
Implementations
impl<'a, V: HasDrop> SliceDrop<'a, V>
[src]
pub fn from_slice<T: Elem>(slice: &[T]) -> Self where
V: VTable<T>,
[src]
V: VTable<T>,
Construct a SliceDrop
from a given typed slice by reusing the provided memory.
impl<'a, V: ?Sized + HasDrop> SliceDrop<'a, V>
[src]
pub fn into_raw_parts(self) -> (&'a [u8], usize, TypeId, VTableRef<'a, V>)
[src]
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 [u8],
element_size: usize,
element_type_id: TypeId,
vtable: impl Into<VTableRef<'a, V>>
) -> Self
[src]
data: &'a [u8],
element_size: usize,
element_type_id: TypeId,
vtable: impl Into<VTableRef<'a, V>>
) -> Self
Construct a SliceDrop
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 upcast<U: From<V>>(self) -> SliceDrop<'a, U> where
V: Clone,
[src]
V: Clone,
Upcast the SliceDrop
into a more general base SliceDrop
.
This function converts the underlying virtual function table into a subset of the existing
pub fn check<T: Any>(&self) -> Option<&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) -> SliceDrop<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 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 element_size(&self) -> usize
[src]
Get the size of the element type in bytes.
pub fn iter_as<T: Any>(&self) -> Option<Iter<T>>
[src]
Return an iterator to a slice representing typed data.
Returns None
if the given type T
doesn't match the internal.
Examples
use dync::SliceDrop; let vec = vec![1.0_f32, 23.0, 0.01, 42.0, 11.43]; let buf: SliceDrop = vec.as_slice().into(); for (i, &val) in buf.iter_as::<f32>().unwrap().enumerate() { assert_eq!(val, vec[i]); }
pub fn as_slice<T: Any>(&self) -> Option<&[T]>
[src]
Borrow this slice as a typed slice.
Returns None
if the given type T
doesn't match the internal.
pub fn get_as<T: Elem>(&self, i: usize) -> Option<&T>
[src]
Get i
'th element of the buffer.
pub fn iter(&self) -> impl Iterator<Item = ValueRef<V>>
[src]
Return an iterator over untyped value references stored in this buffer.
In contrast to iter
, 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.
Examples
use dync::SliceDrop; let vec = vec![1.0_f32, 23.0, 0.01, 42.0, 11.43]; let buf: SliceDrop = vec.as_slice().into(); for (i, val) in buf.iter().enumerate() { assert_eq!(val.downcast::<f32>().unwrap(), &vec[i]); }
pub fn chunks_exact(
&self,
chunk_size: usize
) -> impl Iterator<Item = SliceDrop<V>>
[src]
&self,
chunk_size: usize
) -> impl Iterator<Item = SliceDrop<V>>
pub fn split_at(&self, mid: usize) -> (SliceDrop<V>, SliceDrop<V>)
[src]
pub fn get(&self, i: usize) -> ValueRef<V>
[src]
Get a reference to a value stored in this container at index i
.
pub fn subslice<I>(&self, i: I) -> SliceDrop<V> where
I: SliceIndex<[u8], Output = [u8]> + ScaleRange,
[src]
I: SliceIndex<[u8], Output = [u8]> + ScaleRange,
Get an immutable subslice representing the given range of indices.
pub fn into_subslice<I>(self, i: I) -> SliceDrop<'a, V> where
I: SliceIndex<[u8], Output = [u8]> + ScaleRange,
[src]
I: SliceIndex<[u8], Output = [u8]> + ScaleRange,
Convert this slice into an immutable subslice representing the given range of indices.
impl<'a, V: ?Sized + HasClone + HasDrop> SliceDrop<'a, V>
[src]
pub fn append_clone_to_vec<'b, T: Elem + Clone>(
&self,
vec: &'b mut Vec<T>
) -> Option<&'b mut Vec<T>>
[src]
&self,
vec: &'b mut Vec<T>
) -> Option<&'b mut Vec<T>>
Append cloned 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 clone_into_vec<T: Elem + Clone>(&self) -> Option<Vec<T>>
[src]
Clones contents of self
into the given Vec
.
Trait Implementations
impl<'a, V> Clone for SliceDrop<'a, V> where
V: Clone + ?Sized,
[src]
V: Clone + ?Sized,
impl<'a, T, V> From<&'a [T]> for SliceDrop<'a, V> where
T: Elem,
V: VTable<T> + HasDrop,
[src]
T: Elem,
V: VTable<T> + HasDrop,
Convert a &[T]
to a SliceDrop
.
impl<'b, 'a: 'b, V: ?Sized + HasDrop> From<&'b SliceDropMut<'a, V>> for SliceDrop<'b, V>
[src]
fn from(s: &'b SliceDropMut<'a, V>) -> SliceDrop<'b, V>
[src]
impl<'a, V> From<SliceDrop<'a, V>> for Meta<VTableRef<'a, V>>
[src]
impl<'a, V: Clone> From<SliceDrop<'a, V>> for Meta<Ptr<V>>
[src]
impl<'a, V: ?Sized> From<SliceDropMut<'a, V>> for SliceDrop<'a, V>
[src]
fn from(s: SliceDropMut<'a, V>) -> SliceDrop<'a, V>
[src]
impl<'a, V: ?Sized + HasDrop + HasSend> Send for SliceDrop<'a, V>
[src]
impl<'a, V: ?Sized + HasDrop + HasSync> Sync for SliceDrop<'a, V>
[src]
Auto Trait Implementations
impl<'a, V: ?Sized> RefUnwindSafe for SliceDrop<'a, V> where
V: RefUnwindSafe,
V: RefUnwindSafe,
impl<'a, V: ?Sized> Unpin for SliceDrop<'a, V>
impl<'a, V: ?Sized> UnwindSafe for SliceDrop<'a, V> where
V: RefUnwindSafe + UnwindSafe,
V: RefUnwindSafe + UnwindSafe,
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> CloneBytes for T where
T: 'static + Clone,
[src]
T: 'static + Clone,
unsafe fn clone_bytes(&[u8]) -> Box<[u8]>
[src]
unsafe fn clone_from_bytes(&mut [u8], &[u8])
[src]
unsafe fn clone_into_raw_bytes(&[u8], &mut [u8])
[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 [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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,