Skip to main content

Expr

Enum Expr 

Source
pub enum Expr<'a> {
Show 61 variants Text(Text<'a>), Space(Space<'a>), Linebreak(Linebreak<'a>), Parbreak(Parbreak<'a>), Escape(Escape<'a>), Shorthand(Shorthand<'a>), SmartQuote(SmartQuote<'a>), Strong(Strong<'a>), Emph(Emph<'a>), Raw(Raw<'a>), Link(Link<'a>), Label(Label<'a>), Ref(Ref<'a>), Heading(Heading<'a>), ListItem(ListItem<'a>), EnumItem(EnumItem<'a>), TermItem(TermItem<'a>), Equation(Equation<'a>), Math(Math<'a>), MathText(MathText<'a>), MathIdent(MathIdent<'a>), MathFieldAccess(MathFieldAccess<'a>), MathShorthand(MathShorthand<'a>), MathAlignPoint(MathAlignPoint<'a>), MathCall(MathCall<'a>), MathDelimited(MathDelimited<'a>), MathAttach(MathAttach<'a>), MathPrimes(MathPrimes<'a>), MathFrac(MathFrac<'a>), MathRoot(MathRoot<'a>), Ident(Ident<'a>), None(None<'a>), Auto(Auto<'a>), Bool(Bool<'a>), Int(Int<'a>), Float(Float<'a>), Numeric(Numeric<'a>), Str(Str<'a>), CodeBlock(CodeBlock<'a>), ContentBlock(ContentBlock<'a>), Parenthesized(Parenthesized<'a>), Array(Array<'a>), Dict(Dict<'a>), Unary(Unary<'a>), Binary(Binary<'a>), FieldAccess(FieldAccess<'a>), FuncCall(FuncCall<'a>), Closure(Closure<'a>), LetBinding(LetBinding<'a>), DestructAssignment(DestructAssignment<'a>), SetRule(SetRule<'a>), ShowRule(ShowRule<'a>), Contextual(Contextual<'a>), Conditional(Conditional<'a>), WhileLoop(WhileLoop<'a>), ForLoop(ForLoop<'a>), ModuleImport(ModuleImport<'a>), ModuleInclude(ModuleInclude<'a>), LoopBreak(LoopBreak<'a>), LoopContinue(LoopContinue<'a>), FuncReturn(FuncReturn<'a>),
}
Expand description

An expression in markup, math or code.

Variants§

§

Text(Text<'a>)

Plain text without markup.

§

Space(Space<'a>)

Whitespace in markup or math. Has at most one newline in markup, as more indicate a paragraph break.

§

Linebreak(Linebreak<'a>)

A forced line break: \.

§

Parbreak(Parbreak<'a>)

A paragraph break, indicated by one or multiple blank lines.

§

Escape(Escape<'a>)

An escape sequence: \#, \u{1F5FA}.

§

Shorthand(Shorthand<'a>)

A shorthand for a unicode codepoint. For example, ~ for non-breaking space or -? for a soft hyphen.

§

SmartQuote(SmartQuote<'a>)

A smart quote: ' or ".

§

Strong(Strong<'a>)

Strong content: *Strong*.

§

Emph(Emph<'a>)

Emphasized content: _Emphasized_.

§

Raw(Raw<'a>)

Raw text with optional syntax highlighting: `...`.

A hyperlink: https://typst.org.

§

Label(Label<'a>)

A label: <intro>.

§

Ref(Ref<'a>)

A reference: @target, @target[..].

§

Heading(Heading<'a>)

A section heading: = Introduction.

§

ListItem(ListItem<'a>)

An item in a bullet list: - ....

§

EnumItem(EnumItem<'a>)

An item in an enumeration (numbered list): + ... or 1. ....

§

TermItem(TermItem<'a>)

An item in a term list: / Term: Details.

§

Equation(Equation<'a>)

A mathematical equation: $x$, $ x^2 $.

§

Math(Math<'a>)

The contents of a mathematical equation: x^2 + 1.

§

MathText(MathText<'a>)

A lone text fragment in math: x, 25, 3.1415, =, [.

§

MathIdent(MathIdent<'a>)

An identifier in math: pi.

§

MathFieldAccess(MathFieldAccess<'a>)

A field access in math: arrow.r.long.double.bar.

§

MathShorthand(MathShorthand<'a>)

A shorthand for a unicode codepoint in math: a <= b.

§

MathAlignPoint(MathAlignPoint<'a>)

An alignment point in math: &.

§

MathCall(MathCall<'a>)

A function call in math: mat(delim: "[", a, b; ..#($c$,), d)

§

MathDelimited(MathDelimited<'a>)

Matched delimiters in math: [x + y].

§

MathAttach(MathAttach<'a>)

A base with optional attachments in math: a_1^2.

§

MathPrimes(MathPrimes<'a>)

Grouped primes in math: a'''.

§

MathFrac(MathFrac<'a>)

A fraction in math: x/2.

§

MathRoot(MathRoot<'a>)

A root in math: √x, ∛x or ∜x.

§

Ident(Ident<'a>)

An identifier: left.

§

None(None<'a>)

The none literal.

§

Auto(Auto<'a>)

The auto literal.

§

Bool(Bool<'a>)

A boolean: true, false.

§

Int(Int<'a>)

An integer: 120.

§

Float(Float<'a>)

A floating-point number: 1.2, 10e-4.

§

Numeric(Numeric<'a>)

A numeric value with a unit: 12pt, 3cm, 2em, 90deg, 50%.

§

Str(Str<'a>)

A quoted string: "...".

§

CodeBlock(CodeBlock<'a>)

A code block: { let x = 1; x + 2 }.

§

ContentBlock(ContentBlock<'a>)

A content block: [*Hi* there!].

§

Parenthesized(Parenthesized<'a>)

A grouped expression: (1 + 2).

§

Array(Array<'a>)

An array: (1, "hi", 12cm).

§

Dict(Dict<'a>)

A dictionary: (thickness: 3pt, dash: "solid").

§

Unary(Unary<'a>)

A unary operation: -x.

§

Binary(Binary<'a>)

A binary operation: a + b.

§

FieldAccess(FieldAccess<'a>)

A field access: properties.age.

§

FuncCall(FuncCall<'a>)

An invocation of a function or method: f(x, y).

§

Closure(Closure<'a>)

A closure: (x, y) => z.

§

LetBinding(LetBinding<'a>)

A let binding: let x = 1.

§

DestructAssignment(DestructAssignment<'a>)

A destructuring assignment: (x, y) = (1, 2).

§

SetRule(SetRule<'a>)

A set rule: set text(...).

§

ShowRule(ShowRule<'a>)

A show rule: show heading: it => emph(it.body).

§

Contextual(Contextual<'a>)

A contextual expression: context text.lang.

§

Conditional(Conditional<'a>)

An if-else conditional: if x { y } else { z }.

§

WhileLoop(WhileLoop<'a>)

A while loop: while x { y }.

§

ForLoop(ForLoop<'a>)

A for loop: for x in y { z }.

§

ModuleImport(ModuleImport<'a>)

A module import: import "utils.typ": a, b, c.

§

ModuleInclude(ModuleInclude<'a>)

A module include: include "chapter1.typ".

§

LoopBreak(LoopBreak<'a>)

A break from a loop: break.

§

LoopContinue(LoopContinue<'a>)

A continue in a loop: continue.

§

FuncReturn(FuncReturn<'a>)

A return from a function: return, return x + 1.

Implementations§

Source§

impl Expr<'_>

Source

pub fn hash(self) -> bool

Can this expression be embedded into markup with a hash?

Source

pub fn is_literal(self) -> bool

Is this a literal?

Trait Implementations§

Source§

impl<'a> AstNode<'a> for Expr<'a>

Source§

fn from_untyped(node: &'a SyntaxNode) -> Option<Self>

Convert a node into its typed variant.
Source§

fn to_untyped(self) -> &'a SyntaxNode

A reference to the underlying syntax node.
Source§

fn placeholder() -> Self

A placeholder for this node type. If the underlying CST has syntax errors or did not come from the parser, the AST is not guaranteed to be valid. But instead of panicking in that case, we return placeholder nodes.
Source§

fn span(self) -> Span

The source code location.
Source§

impl<'a> Clone for Expr<'a>

Source§

fn clone(&self) -> Expr<'a>

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<'a> Copy for Expr<'a>

Source§

impl<'a> Debug for Expr<'a>

Source§

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

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

impl<'a> Hash for Expr<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Expr<'a>

§

impl<'a> RefUnwindSafe for Expr<'a>

§

impl<'a> Send for Expr<'a>

§

impl<'a> Sync for Expr<'a>

§

impl<'a> Unpin for Expr<'a>

§

impl<'a> UnsafeUnpin for Expr<'a>

§

impl<'a> UnwindSafe for Expr<'a>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.