Skip to main content

SurfaceDecl

Enum SurfaceDecl 

Source
pub enum SurfaceDecl {
    Notation {
        pattern: String,
        template: String,
        precedence: Option<u32>,
        assoc: Assoc,
        operator_form: Option<OperatorForm>,
    },
    Macro {
        pattern: String,
        template: String,
    },
    OpenSection(Option<String>),
    CloseSection(Option<String>),
    OpenNamespace(Name),
}
Expand description

A declaration that extends the SURFACE rather than the context. Emitted by the command parser, applied by the REPL — so the one place a parser extension can land is the surface environment.

Variants§

§

Notation

Notation "a ⊕ b" := ((myOp a) b). and the fixity spellings, which are the same thing with the shape and associativity given by the command word instead of by the pattern.

Fields

§pattern: String
§template: String
§precedence: Option<u32>
§assoc: Assoc
§operator_form: Option<OperatorForm>

For Infixl/Infixr/Prefix/Postfix, the operator’s own spelling: the pattern is just the token and the holes are implied.

§

Macro

Macro "twiceIt $e" := … / MacroRules "nested![$x, $xs]" := ….

Fields

§pattern: String
§template: String
§

OpenSection(Option<String>)

Section First. — or a bare Section., which is Lean’s ANONYMOUS section (section with no name), the ordinary way to scope a local without inventing a label for it. None is that form.

§

CloseSection(Option<String>)

End First. — and, when the innermost open scope is a NAMESPACE of that name, the close of that namespace instead. Lean spells both with one keyword and decides by what is open; deciding it here rather than in the parser is what lets the parser stay text-only.

None is the bare End. that closes an anonymous section. It closes ONLY an anonymous one: lean 4.14.0 answers namespace N … end with invalid 'end', name is missing (expected N), and a bare End that silently closed a named scope would leave every later declaration somewhere nobody wrote.

§

OpenNamespace(Name)

Namespace Outer.Inner. — a namespace declarations are written INTO and short names resolve against. Nothing is declared: like every other surface declaration this changes how a name is spelled and read, never what exists.

Trait Implementations§

Source§

impl Clone for SurfaceDecl

Source§

fn clone(&self) -> SurfaceDecl

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 SurfaceDecl

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.