Skip to main content

Decl

Enum Decl 

Source
pub enum Decl {
Show 18 variants Axiom { name: String, univ_params: Vec<String>, ty: Located<SurfaceExpr>, attrs: Vec<AttributeKind>, }, Definition { name: String, univ_params: Vec<String>, ty: Option<Located<SurfaceExpr>>, val: Located<SurfaceExpr>, where_clauses: Vec<WhereClause>, attrs: Vec<AttributeKind>, }, Theorem { name: String, univ_params: Vec<String>, ty: Located<SurfaceExpr>, proof: Located<SurfaceExpr>, where_clauses: Vec<WhereClause>, attrs: Vec<AttributeKind>, }, Inductive { name: String, univ_params: Vec<String>, params: Vec<Binder>, indices: Vec<Binder>, ty: Located<SurfaceExpr>, ctors: Vec<Constructor>, }, Import { path: Vec<String>, }, Namespace { name: String, decls: Vec<Located<Decl>>, }, Structure { name: String, univ_params: Vec<String>, extends: Vec<String>, fields: Vec<FieldDecl>, }, ClassDecl { name: String, univ_params: Vec<String>, extends: Vec<String>, fields: Vec<FieldDecl>, }, InstanceDecl { name: Option<String>, class_name: String, ty: Located<SurfaceExpr>, defs: Vec<(String, Located<SurfaceExpr>)>, }, SectionDecl { name: String, decls: Vec<Located<Decl>>, }, Variable { binders: Vec<Binder>, }, Open { path: Vec<String>, names: Vec<String>, }, Attribute { attrs: Vec<String>, decl: Box<Located<Decl>>, }, HashCmd { cmd: String, arg: Located<SurfaceExpr>, }, Mutual { decls: Vec<Located<Decl>>, }, Derive { instances: Vec<String>, type_name: String, }, NotationDecl { kind: AstNotationKind, prec: Option<u32>, name: String, notation: String, }, Universe { names: Vec<String>, },
}
Expand description

Top-level declaration.

Variants§

§

Axiom

Axiom declaration

Fields

§name: String

Name

§univ_params: Vec<String>

Universe parameters

§attrs: Vec<AttributeKind>

Attributes

§

Definition

Definition

Fields

§name: String

Name

§univ_params: Vec<String>

Universe parameters

§ty: Option<Located<SurfaceExpr>>

Type (optional, can be inferred)

§where_clauses: Vec<WhereClause>

Where clauses (local definitions)

§attrs: Vec<AttributeKind>

Attributes

§

Theorem

Theorem

Fields

§name: String

Name

§univ_params: Vec<String>

Universe parameters

§ty: Located<SurfaceExpr>

Type (statement)

§proof: Located<SurfaceExpr>

Proof

§where_clauses: Vec<WhereClause>

Where clauses (local definitions)

§attrs: Vec<AttributeKind>

Attributes

§

Inductive

Inductive type

Fields

§name: String

Name

§univ_params: Vec<String>

Universe parameters

§params: Vec<Binder>

Parameters (non-varying)

§indices: Vec<Binder>

Indices (varying)

§ctors: Vec<Constructor>

Constructors

§

Import

Import declaration

Fields

§path: Vec<String>

Module path

§

Namespace

Namespace declaration

Fields

§name: String

Namespace name

§decls: Vec<Located<Decl>>

Declarations inside

§

Structure

Structure declaration

Fields

§name: String

Structure name

§univ_params: Vec<String>

Universe parameters

§extends: Vec<String>

Parent structures (extends)

§fields: Vec<FieldDecl>

Fields

§

ClassDecl

Class declaration

Fields

§name: String

Class name

§univ_params: Vec<String>

Universe parameters

§extends: Vec<String>

Parent classes (extends)

§fields: Vec<FieldDecl>

Fields/methods

§

InstanceDecl

Instance declaration

Fields

§name: Option<String>

Optional instance name

§class_name: String

Class being instantiated

§ty: Located<SurfaceExpr>

The instance type

§defs: Vec<(String, Located<SurfaceExpr>)>

Method definitions

§

SectionDecl

Section declaration

Fields

§name: String

Section name

§decls: Vec<Located<Decl>>

Declarations inside

§

Variable

Variable declaration

Fields

§binders: Vec<Binder>

Binders

§

Open

Open declaration

Fields

§path: Vec<String>

Module path

§names: Vec<String>

Specific names to open (empty = open all)

§

Attribute

Attribute declaration

Fields

§attrs: Vec<String>

Attribute names

§decl: Box<Located<Decl>>

Inner declaration

§

HashCmd

Hash command (#check, #eval, #print)

Fields

§cmd: String

Command name (e.g. “check”, “eval”, “print”)

§arg: Located<SurfaceExpr>

Argument expression

§

Mutual

Mutual recursive definitions

Fields

§decls: Vec<Located<Decl>>

The mutually recursive declarations

§

Derive

Derive declaration: deriving instance1, instance2 for TypeName

Fields

§instances: Vec<String>

Instance strategies to derive

§type_name: String

Type name to derive for

§

NotationDecl

Notation declaration

Fields

§kind: AstNotationKind

Kind of notation

§prec: Option<u32>

Precedence (optional)

§name: String

Name or symbol

§notation: String

Notation body

§

Universe

Universe declaration: universe u v w

Fields

§names: Vec<String>

Universe variable names

Implementations§

Source§

impl Decl

Source

pub fn name(&self) -> Option<&str>

Get the name of this declaration, if it has one.

Source

pub fn typed_attrs(&self) -> &[AttributeKind]

Get the attributes if this declaration has typed attributes.

Source

pub fn is_mutual(&self) -> bool

Check if this declaration is a mutual block.

Trait Implementations§

Source§

impl Clone for Decl

Source§

fn clone(&self) -> Decl

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Decl

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Decl

Source§

fn eq(&self, other: &Decl) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Decl

Auto Trait Implementations§

§

impl Freeze for Decl

§

impl RefUnwindSafe for Decl

§

impl Send for Decl

§

impl Sync for Decl

§

impl Unpin for Decl

§

impl UnsafeUnpin for Decl

§

impl UnwindSafe for Decl

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.