pub struct VariantDecl {
pub name: String,
pub params: usize,
pub ctors: Vec<(String, Option<MonoType>)>,
pub param_vars: Vec<TyVarRef>,
}Expand description
A user (or built-in) variant type declaration.
param_vars names the declaration’s type parameters as concrete
placeholder TyVarRefs that appear (via MonoType::Var) inside
ctors’ payload types; they are never meant to be unified against
anything directly. VariantDecl::instantiate_ctor is the only
sanctioned way to use a declaration: given concrete argument types for
the variant’s params type parameters, it substitutes them for the
placeholders (matched by pointer identity, the same mechanism
types::instantiate uses for quantified variables — see
types::substitute) throughout the chosen constructor’s payload type,
and returns both that payload type and the resulting
MonoType::Variant(name, args).
This mirrors v0.0.6’s Typeenv.Raw.register_type/add_constructor
(primitives.cppo.ml:154-217), which pairs a TypeID.t with a
Typeenv.Data(arity) and each constructor with a Poly(...) scheme
quantified over the same bid/typaram placeholders declared once for
the whole type — the same shape, just spelled with this port’s
TyVarRef/substitute machinery instead of v0.0.6’s BoundID/
PolyBound.
Fields§
§name: String§params: usize§ctors: Vec<(String, Option<MonoType>)>§param_vars: Vec<TyVarRef>Trait Implementations§
Source§impl Clone for VariantDecl
impl Clone for VariantDecl
Source§fn clone(&self) -> VariantDecl
fn clone(&self) -> VariantDecl
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for VariantDecl
impl !Send for VariantDecl
impl !Sync for VariantDecl
impl !UnwindSafe for VariantDecl
impl Freeze for VariantDecl
impl Unpin for VariantDecl
impl UnsafeUnpin for VariantDecl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more