Trait possibly_uninit::zeroed::PtrCount[][src]

pub unsafe trait PtrCount: PtrCount {
    type Item: Sized;
    fn ptr_count(&self) -> (*const Self::Item, usize);
fn ptr_count_mut(&mut self) -> (*mut Self::Item, usize); fn as_slice(&self) -> &[Self::Item] { ... }
fn as_slice_mut(&mut self) -> &mut [Self::Item]
    where
        Self: AnyValid
, { ... } }

Trait unifying T and [T]

This trait is used to make writing zeroes easier.

Safety

The trait is unsafe because returning invalid values from ptr_coun* methods is udefined behavior.

Associated Types

type Item: Sized[src]

Either Self or type of item in the slice.

Loading content...

Required methods

fn ptr_count(&self) -> (*const Self::Item, usize)[src]

Returns a pointer pointing to the first item and the count of items.

This is only defined for sized types, in which case it must return pointer to the value and count 1 and for slices, when it must return pointer to the zeroth item of the slice and length of the slice.

It’s undefined for trait objects so, the trait is sealed.

fn ptr_count_mut(&mut self) -> (*mut Self::Item, usize)[src]

Returns a mutable pointer pointing to the first item and the count of items.

This is only defined for sized types, in which case it must return pointer to the value and count 1 and for slices, when it must return pointer to the zeroth item of the slice and length of the slice.

It’s undefined for trait objects so, the trait is sealed.

Loading content...

Provided methods

fn as_slice(&self) -> &[Self::Item][src]

Helper that turns the value into slice based on ptr and count

fn as_slice_mut(&mut self) -> &mut [Self::Item] where
    Self: AnyValid
[src]

Helper that turns the value into mutable slice based on ptr and count

Loading content...

Implementors

impl PtrCount for str[src]

type Item = u8

impl<T> PtrCount for T[src]

type Item = T

impl<T> PtrCount for [T][src]

type Item = T

Loading content...