Skip to main content

Surface

Struct Surface 

Source
pub struct Surface { /* private fields */ }
Expand description

The surface environment: a stack of scopes, innermost last.

Implementations§

Source§

impl Surface

Source

pub fn new() -> Surface

A surface with nothing declared. The parse path it produces is byte-identical to having no surface at all, which is what keeps the extension point free when nobody uses it.

Source

pub fn namespaces(&self) -> &Namespaces

The namespace scope: what is current, what is open.

Source

pub fn namespaces_mut(&mut self) -> &mut Namespaces

The namespace scope, to push and wind back a SCOPED opening — Open … in <command>, and a declaration whose own name names the namespace it is written into.

Source

pub fn enter_declaration(&mut self, declared: &Name) -> (String, ScopeMark)

Enter the scope a DECLARATION named declared elaborates in, and give back the absolute key it declares. See Namespaces::enter_declaration; this is the door, because only the surface knows how deep the section stack is, and that is what orders the two scope stacks.

Source

pub fn is_empty(&self) -> bool

Is anything declared? A surface with no notations and no macros is skipped entirely.

Source

pub fn section_depth(&self) -> usize

How many SECTIONS are open. The root scope is never pushed and never popped, so it is not one of them.

Source

pub fn section_names(&self) -> Vec<String>

The open sections, outermost first \u{2014} what a document must close before it ends. An anonymous section is named AS one rather than as the empty string, so an unbalanced document reports something a reader can act on.

Source

pub fn close_sections_to(&mut self, depth: usize)

Close every section opened since depth. Only ever SHRINKS: a section already closed took its notations with it and cannot be brought back, which is why an over-closing document is reported rather than silently repaired.

Source

pub fn declare(&mut self, decl: SurfaceDecl) -> Result<(), ParseError>

Apply one surface declaration.

Source

pub fn expand_macros(&self, text: &str) -> Result<String, ParseError>

Rewrite every macro invocation in text until none remains.

Text in, text out, because an alternative may invoke the macro it is defining (nested![$x, $xs] expands to a mycons applied to nested![$xs]) and that inner call can only be matched once its argument is known. The step budget is a hard backstop: a recursive rule that never reaches its base case FAILS rather than hangs.

Trait Implementations§

Source§

impl Debug for Surface

Source§

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

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

impl Default for Surface

Source§

fn default() -> Surface

Returns the “default value” for a type. 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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,