Skip to main content

RawMemory

Struct RawMemory 

Source
pub struct RawMemory<T> { /* private fields */ }
Expand description

Allocates uninitialized memory on the heap. When it goes out of scope the memory is released. The user has to ensure that the memory is initialized.

Implementations§

Source§

impl<T> RawMemory<T>

Source

pub fn new<F>(fill: F) -> RawMemory<T>
where F: FnMut(usize) -> u8,

Allocates memory to fit in a T and fills the memory with values provided by the fill callback.

Source

pub fn new_zeroed() -> RawMemory<T>

Allocates zeroed memory to fit in a T.

Source

pub fn new_filled(value: u8) -> RawMemory<T>

Allocates memory filled with a given value to fit in a T.

Source

pub fn as_ptr(&self) -> *const T

Returns a const pointer to T

Source

pub fn as_mut_ptr(&self) -> *mut T

Returns a mutable pointer to T

Source

pub unsafe fn assume_init(&self) -> &T

Returns a const reference to T

§Safety
  • T must have been constructed manually before calling this function.
Source

pub unsafe fn assume_init_mut(&mut self) -> &mut T

Returns a mutable reference to T

§Safety
  • T must have been constructed manually before calling this function.
Source

pub fn as_slice(&self) -> &[u8]

Returns a slice to the underlying memory

Source

pub fn as_slice_mut(&mut self) -> &mut [u8]

Returns a mutable slice to the underlying memory

Trait Implementations§

Source§

impl<T> Drop for RawMemory<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<T> !Send for RawMemory<T>

§

impl<T> !Sync for RawMemory<T>

§

impl<T> Freeze for RawMemory<T>

§

impl<T> RefUnwindSafe for RawMemory<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for RawMemory<T>

§

impl<T> UnsafeUnpin for RawMemory<T>

§

impl<T> UnwindSafe for RawMemory<T>
where T: RefUnwindSafe,

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, 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.