Skip to main content

Generic

Struct Generic 

Source
pub struct Generic<'a, const N: usize>(/* private fields */);
Expand description

A Lean value of a type that a declaration bound to Rust is generic in.

The Rust function behind such a declaration is generic in the type as well, and this is what the type is when Lean calls it. So the function can pass the value on, hold it for the length of the call, clone it and give it back, and cannot look inside: all that a value of an unknown type allows, in Rust as in Lean. It is a Lean object, so it stays on the thread it is on.

Each type a declaration is generic in is a type of its own in Rust: N is the type’s place among the declaration’s type parameters. A Rust function therefore has to be generic in each of them apart. One that takes two values as one type, where they have two types in Lean, could give Lean a value of one type as a value of the other, and does not compile.

The lifetime closes the other way to do that. It is the call’s own, so the type is not 'static, and a value cannot be kept in a place that outlives the call or be told apart at run time.

Trait Implementations§

Source§

impl<const N: usize> Clone for Generic<'_, N>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Drop for Generic<'_, N>

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<'a, const N: usize> !RefUnwindSafe for Generic<'a, N>

§

impl<'a, const N: usize> !Send for Generic<'a, N>

§

impl<'a, const N: usize> !Sync for Generic<'a, N>

§

impl<'a, const N: usize> !UnwindSafe for Generic<'a, N>

§

impl<'a, const N: usize> Forget for Generic<'a, N>

§

impl<'a, const N: usize> Freeze for Generic<'a, N>

§

impl<'a, const N: usize> Move for Generic<'a, N>

§

impl<'a, const N: usize> Unpin for Generic<'a, N>
where *mut Header: Unpin, &'a (): Unpin,

§

impl<'a, const N: usize> UnsafeUnpin for Generic<'a, N>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.