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.