pub enum Decl {
Show 22 variants
Func(SpannedDecl),
ImportAlias(SpannedDecl),
Var(SpannedDecl),
IdentRef(SpannedDecl),
Module(ModuleDecl),
ModuleAlias(SpannedDecl),
PathStem(SpannedDecl),
ImportPath(SpannedDecl),
IncludePath(SpannedDecl),
Import(SpannedDecl),
ContentRef(SpannedDecl),
Label(SpannedDecl),
StrName(SpannedDecl),
ModuleImport(SpanDecl),
Closure(SpanDecl),
Pattern(SpanDecl),
Spread(SpanDecl),
Content(SpanDecl),
Constant(SpanDecl),
BibEntry(NameRangeDecl),
Docs(DocsDecl),
Generated(GeneratedDecl),
}Expand description
Represents different kinds of declarations in the language.
Variants§
Func(SpannedDecl)
A function declaration: (x, y) => x + y
ImportAlias(SpannedDecl)
An import alias declaration: import "path.typ": x
Var(SpannedDecl)
A variable declaration: let x = 1
IdentRef(SpannedDecl)
An identifier reference declaration: x
Module(ModuleDecl)
A module declaration: import calc
ModuleAlias(SpannedDecl)
A module alias declaration: import "path.typ" as x
PathStem(SpannedDecl)
A path stem declaration: path.typ
ImportPath(SpannedDecl)
An import path declaration: import "path.typ"
IncludePath(SpannedDecl)
An include path declaration: include "path.typ"
Import(SpannedDecl)
An import declaration: import "path.typ"
ContentRef(SpannedDecl)
A content reference declaration: @x
Label(SpannedDecl)
A label declaration: label
StrName(SpannedDecl)
A string name declaration: "x"
ModuleImport(SpanDecl)
A module import declaration: import "path.typ": *
Closure(SpanDecl)
A closure declaration: (x, y) => x + y
Pattern(SpanDecl)
A pattern declaration: let (x, y, ..z) = 1
Spread(SpanDecl)
A spread declaration: ..z
Content(SpanDecl)
A content declaration: #[text]
Constant(SpanDecl)
A constant declaration: let x = 1
BibEntry(NameRangeDecl)
A bib entry declaration: @entry
Docs(DocsDecl)
A docs declaration created by the compiler.
Generated(GeneratedDecl)
A generated declaration created by the compiler.
Implementations§
Source§impl Decl
impl Decl
Sourcepub fn lit_(name: Interned<str>) -> Self
pub fn lit_(name: Interned<str>) -> Self
Creates a variable declaration from an interned string.
Sourcepub fn import_alias(ident: Ident<'_>) -> Self
pub fn import_alias(ident: Ident<'_>) -> Self
Creates an import alias declaration from an identifier.
Sourcepub fn ident_ref(ident: Ident<'_>) -> Self
pub fn ident_ref(ident: Ident<'_>) -> Self
Creates an identifier reference declaration from an identifier.
Sourcepub fn math_ident_ref(ident: MathIdent<'_>) -> Self
pub fn math_ident_ref(ident: MathIdent<'_>) -> Self
Creates an identifier reference declaration from a math identifier.
Sourcepub fn module_with_name(name: Interned<str>, fid: TypstFileId) -> Self
pub fn module_with_name(name: Interned<str>, fid: TypstFileId) -> Self
Creates a module declaration with a name and a file ID.
Sourcepub fn module_alias(ident: Ident<'_>) -> Self
pub fn module_alias(ident: Ident<'_>) -> Self
Creates a module alias declaration from an identifier.
Sourcepub fn ref_(ident: Ref<'_>) -> Self
pub fn ref_(ident: Ref<'_>) -> Self
Creates a content reference declaration from a reference AST node.
Sourcepub fn str_name(s: SyntaxNode, name: &str) -> Decl
pub fn str_name(s: SyntaxNode, name: &str) -> Decl
Creates a string name declaration from a syntax node and name.
Sourcepub fn calc_path_stem(s: &str) -> Interned<str>
pub fn calc_path_stem(s: &str) -> Interned<str>
Calculates the path stem from a string path or package specification.
For package specs (starting with ‘@’), extracts the package name. For file paths, extracts the file stem. Returns empty string if extraction fails.
Sourcepub fn path_stem(s: SyntaxNode, name: Interned<str>) -> Self
pub fn path_stem(s: SyntaxNode, name: Interned<str>) -> Self
Creates a path stem declaration from a syntax node and name.
Sourcepub fn import_path(s: Span, name: Interned<str>) -> Self
pub fn import_path(s: Span, name: Interned<str>) -> Self
Creates an import path declaration with a span and name.
Sourcepub fn include_path(s: Span, name: Interned<str>) -> Self
pub fn include_path(s: Span, name: Interned<str>) -> Self
Creates an include path declaration with a span and name.
Sourcepub fn module_import(s: Span) -> Self
pub fn module_import(s: Span) -> Self
Creates a module import declaration with just a span.
Sourcepub fn docs(base: Interned<Decl>, var: Interned<TypeVar>) -> Self
pub fn docs(base: Interned<Decl>, var: Interned<TypeVar>) -> Self
Creates a documentation declaration linking a base declaration with a type variable.
Sourcepub fn bib_entry(
name: Interned<str>,
fid: TypstFileId,
name_range: Range<usize>,
range: Option<Range<usize>>,
) -> Self
pub fn bib_entry( name: Interned<str>, fid: TypstFileId, name_range: Range<usize>, range: Option<Range<usize>>, ) -> Self
Creates a bibliography entry declaration.
Sourcepub fn is_def(&self) -> bool
pub fn is_def(&self) -> bool
Checks if this declaration represents a definition rather than a reference (usage of a definition).
Sourcepub fn full_range(&self) -> Option<Range<usize>>
pub fn full_range(&self) -> Option<Range<usize>>
Gets full range of the declaration.
Trait Implementations§
Source§impl Internable for Decl
impl Internable for Decl
fn storage() -> &'static InternStorage<Self>
Source§impl Ord for Decl
impl Ord for Decl
Source§impl PartialOrd for Decl
impl PartialOrd for Decl
impl Eq for Decl
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 UnwindSafe for Decl
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Filterable for T
impl<T> Filterable for T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> InternSize for T
impl<T> InternSize for T
const INTERN_SIZE: usize = const INTERN_SIZE: usize = std::mem::size_of::<T>();
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more