Struct r3_core::closure::ClosureEnv

source ·
#[repr(transparent)]
pub struct ClosureEnv(_);
Expand description

The environment parameter type for Closure. It’s ABI-compatible with *mut () but might not be fully initialized.

It’s something that would usually be just intptr_t or void * in C code. It’s designed to have the following properties:

  • It’s ABI-compatible with a C pointer, making it possible to pass the components of a Closure to kernel implementations written in inline assembly or other languages without needing to wrap it with another trampoline.

  • Unlike dyn FnOnce(), it doesn’t waste memory for vtable, most entries of which will never be used for static closures.

  • Constructing it from a pointer doens’t require a pointer-to-integer cast, which is disallowed in a constant context.

Currently it must be filled with initialized bytes because of compiler restrictions. This may change in the future.

Trait Implementations§

source§

impl Clone for ClosureEnv

source§

fn clone(&self) -> ClosureEnv

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
source§

impl Debug for ClosureEnv

source§

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

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

impl Default for ClosureEnv

source§

const fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Init for ClosureEnv

source§

const INIT: Self = _

The default value.
source§

impl Copy for ClosureEnv

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.