Skip to main content

DataConstructor

Struct DataConstructor 

Source
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: Span

Trait Implementations§

Source§

impl Clone for DataConstructor

Source§

fn clone(&self) -> DataConstructor

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 Debug for DataConstructor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.