Skip to main content

Value

Struct Value 

Source
pub struct Value<C: Codec>(/* private fields */);
Expand description

A Lean value of the type C stands for, with the one reference to it that the holder owns. Dropping it gives the reference up.

A value of a type that Lean passes as a scalar is that scalar. A codec of such a type accepts every scalar in Codec::from_lean, which is what lets Value::from_scalar be safe.

Implementations§

Source§

impl<C: Codec> Value<C>

Source

pub unsafe fn from_raw(repr: C::Repr) -> Value<C>

§Safety

repr is a value of the Lean type C stands for, produced by this runtime, and the caller owns a reference to it.

Source

pub fn from_scalar(repr: C::Repr) -> Value<C>
where C::Repr: Scalar,

The value of a type that Lean passes as a scalar.

Source

pub fn into_raw(self) -> C::Repr

The representation, with the reference.

Source

pub fn as_raw(&self) -> C::Repr

The representation, for a function that borrows it. The reference stays here.

Source

pub fn into_object(self) -> Obj

The value as an object; see Repr::into_object.

Source

pub unsafe fn take(object: Obj) -> Value<C>

The value out of an object whose reference is given up.

§Safety

object holds a value of the Lean type C stands for, in the form Value::into_object gives it, and the caller owns a reference to it.

Source

pub unsafe fn share(object: Obj) -> Value<C>

The value out of an object that stays with its owner.

§Safety

object holds a value of the Lean type C stands for, in the form Value::into_object gives it.

Source

pub fn retain(&self) -> Value<C>

The same Lean value, with a reference of its own.

Source

pub unsafe fn cast<D: Codec<Repr = C::Repr>>(self) -> Value<D>

The same value under another codec.

§Safety

D stands for the same Lean type as C.

Trait Implementations§

Source§

impl<C: Codec> Drop for Value<C>

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<C> Forget for Value<C>

§

impl<C> Freeze for Value<C>
where <C as Codec>::Repr: Freeze, PhantomData<C>: Freeze,

§

impl<C> Move for Value<C>

§

impl<C> RefUnwindSafe for Value<C>

§

impl<C> Send for Value<C>
where C: Send, <C as Codec>::Repr: Send,

§

impl<C> Sync for Value<C>
where C: Sync, <C as Codec>::Repr: Sync,

§

impl<C> Unpin for Value<C>
where C: Unpin, <C as Codec>::Repr: Unpin,

§

impl<C> UnsafeUnpin for Value<C>

§

impl<C> UnwindSafe for Value<C>
where <C as Codec>::Repr: UnwindSafe, C: UnwindSafe,

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> KeptByLeanForAllThreads for T
where T: Sync,

Source§

impl<T> Pass<T> for T

Source§

fn pass<C>(self) -> Value<C>
where C: Codec<Rust = T>,

Source§

impl<T> Slot<T> for T

Source§

fn of(collection: T) -> T

Source§

fn inner(&self) -> &T

Source§

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

The collection for changing, which is this holder’s alone afterwards.
Source§

fn into_inner(self) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.