pub struct DataConstructor {
pub name: String,
pub fields: Vec<FieldDecl>,
pub arg_types: Vec<Type>,
pub pos: Pos,
pub span: Span,
}Expand description
One constructor alternative in a data/newtype declaration.
Additive analysis truth alongside the decl’s opaque keyword/name; like
Type it is span-bearing but never rendered, so it stays invisible to
daml-fmt (which lays out from byte spans).
The structured form models the common corpus shapes (record with/{}
constructors, positional constructors, enum alternatives). It is partial by
design: rather than record a half-truth, the parser leaves a whole decl’s
constructors empty (opaque) when it meets a shape it does not model —
infix constructors (data T = Int :+: Int), strictness bangs
(data T = T !Int), GADT (data T where), and existential/context
constructors (forall a. MkT a). One additional accepted gap keeps the
first constructor only: a single-line record sum where each alternative is
a with block (data T = A with x : Int | B with y : Int); the multi-line
corpus form parses fully.
Fields§
§name: String§fields: Vec<FieldDecl>Record fields when the constructor uses record syntax
(Asset with amount : Decimal or Foo { x : Int }). Empty for
positional and nullary constructors.
arg_types: Vec<Type>Positional argument types for non-record constructors
(Node Int Text → [Int, Text], Money Decimal → [Decimal]). Empty
for record and nullary constructors, or when the arguments did not parse
cleanly (the constructor is then recorded name-only).
pos: Pos§span: SpanTrait Implementations§
Source§impl Clone for DataConstructor
impl Clone for DataConstructor
Source§fn clone(&self) -> DataConstructor
fn clone(&self) -> DataConstructor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more