artichoke_backend::convert

Struct UnboxedValueGuard

Source
pub struct UnboxedValueGuard<'a, T> { /* private fields */ }

Implementations§

Source§

impl<'a, T> UnboxedValueGuard<'a, T>

Source

pub fn new(value: T) -> Self

Construct a new guard around the given T.

UnboxedValueGuard allows passing around a &mut reference without dropping the T when returning control to mruby C code. This is desirable because the T is owned by the mruby heap until the mruby garbage collector frees the mrb_value that holds it.

Source

pub fn as_inner_ref(&self) -> &T

Get a shared reference to the inner T.

Source

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

Get a unique reference to the inner T.

§Safety

Callers must ensure the raw parts stored in the source mrb_value are not invalidated OR that the raw parts are repacked before an mruby allocation occurs.

Source

pub unsafe fn take(self) -> T

Take the inner T out of the guard.

§Safety

Callers must ensure that T is not dropped. Once T is taken out of the guard, it must ultimately be passed to ManuallyDrop before it is dropped.

An example of safe usage is calling taking an Array out of the guard and then immediately calling Array::into_raw_parts on the returned value.

Trait Implementations§

Source§

impl<'a, T> Debug for UnboxedValueGuard<'a, T>
where T: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> Deref for UnboxedValueGuard<'a, Array>

Source§

type Target = Array

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, T> Deref for UnboxedValueGuard<'a, HeapAllocated<T>>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, T> Deref for UnboxedValueGuard<'a, Immediate<T>>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a> Deref for UnboxedValueGuard<'a, String>

Source§

type Target = String

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, T> DerefMut for UnboxedValueGuard<'a, HeapAllocated<T>>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'a, T> DerefMut for UnboxedValueGuard<'a, Immediate<T>>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a, T> Freeze for UnboxedValueGuard<'a, T>
where T: Freeze,

§

impl<'a, T> RefUnwindSafe for UnboxedValueGuard<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for UnboxedValueGuard<'a, T>
where T: Send,

§

impl<'a, T> Sync for UnboxedValueGuard<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for UnboxedValueGuard<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for UnboxedValueGuard<'a, 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.