Skip to main content

Repr

Trait Repr 

Source
pub trait Repr: Copy {
    // Required methods
    fn into_object(self) -> Obj;
    unsafe fn take(object: Obj) -> Self;
    unsafe fn share(object: Obj) -> Self;
    unsafe fn release(self);
    unsafe fn retain(self) -> Self;
}
Expand description

How Lean passes a value of a type: as an object, or as a scalar it keeps unboxed.

Required Methods§

Source

fn into_object(self) -> Obj

The value as an object: the form it has as an element of an array, an argument of a closure or a field of a polymorphic type. The object takes over the reference.

Source

unsafe fn take(object: Obj) -> Self

The value out of an object that Repr::into_object made, whose reference is given up.

§Safety

object holds a value of this representation and the caller owns a reference to it.

Source

unsafe fn share(object: Obj) -> Self

The value out of an object that stays with its owner: one more reference to an object, a copy of a scalar.

§Safety

object holds a value of this representation.

Source

unsafe fn release(self)

Gives up the reference the value holds. A scalar holds none.

§Safety

The caller owns the reference.

Source

unsafe fn retain(self) -> Self

The same value with a reference of its own.

§Safety

The value is alive.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Repr for f32

Source§

fn into_object(self) -> Obj

Source§

unsafe fn take(x: Obj) -> f32

Source§

unsafe fn share(x: Obj) -> f32

Source§

unsafe fn release(self)

Source§

unsafe fn retain(self) -> f32

Source§

impl Repr for f64

Source§

fn into_object(self) -> Obj

Source§

unsafe fn take(x: Obj) -> f64

Source§

unsafe fn share(x: Obj) -> f64

Source§

unsafe fn release(self)

Source§

unsafe fn retain(self) -> f64

Source§

impl Repr for u8

Source§

fn into_object(self) -> Obj

Source§

unsafe fn take(x: Obj) -> u8

Source§

unsafe fn share(x: Obj) -> u8

Source§

unsafe fn release(self)

Source§

unsafe fn retain(self) -> u8

Source§

impl Repr for u16

Source§

fn into_object(self) -> Obj

Source§

unsafe fn take(x: Obj) -> u16

Source§

unsafe fn share(x: Obj) -> u16

Source§

unsafe fn release(self)

Source§

unsafe fn retain(self) -> u16

Source§

impl Repr for u32

Source§

fn into_object(self) -> Obj

Source§

unsafe fn take(x: Obj) -> u32

Source§

unsafe fn share(x: Obj) -> u32

Source§

unsafe fn release(self)

Source§

unsafe fn retain(self) -> u32

Source§

impl Repr for u64

Source§

fn into_object(self) -> Obj

Source§

unsafe fn take(x: Obj) -> u64

Source§

unsafe fn share(x: Obj) -> u64

Source§

unsafe fn release(self)

Source§

unsafe fn retain(self) -> u64

Source§

impl Repr for usize

Source§

fn into_object(self) -> Obj

Source§

unsafe fn take(x: Obj) -> usize

Source§

unsafe fn share(x: Obj) -> usize

Source§

unsafe fn release(self)

Source§

unsafe fn retain(self) -> usize

Implementors§

Source§

impl Repr for Obj