diff options
| author | Laurenz <laurmaedje@gmail.com> | 2025-06-26 10:06:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-26 08:06:22 +0000 |
| commit | 35809387f88483bfa3d0978cfc3303eba0de632b (patch) | |
| tree | 3db8326bcbe238526d783fd538eaaf9d65457ff7 /crates/typst-library/src/foundations/module.rs | |
| parent | d3caedd813b1ca4379a71eb1b4aa636096d53a04 (diff) | |
Support `in` operator on strings and modules (#6498)
Diffstat (limited to 'crates/typst-library/src/foundations/module.rs')
| -rw-r--r-- | crates/typst-library/src/foundations/module.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/crates/typst-library/src/foundations/module.rs b/crates/typst-library/src/foundations/module.rs index 55d8bab6..14eefca3 100644 --- a/crates/typst-library/src/foundations/module.rs +++ b/crates/typst-library/src/foundations/module.rs @@ -19,11 +19,8 @@ use crate::foundations::{repr, ty, Content, Scope, Value}; /// /// You can access definitions from the module using [field access /// notation]($scripting/#fields) and interact with it using the [import and -/// include syntaxes]($scripting/#modules). Alternatively, it is possible to -/// convert a module to a dictionary, and therefore access its contents -/// dynamically, using the [dictionary constructor]($dictionary/#constructor). +/// include syntaxes]($scripting/#modules). /// -/// # Example /// ```example /// <<< #import "utils.typ" /// <<< #utils.add(2, 5) @@ -34,6 +31,20 @@ use crate::foundations::{repr, ty, Content, Scope, Value}; /// >>> /// >>> #(-3) /// ``` +/// +/// You can check whether a definition is present in a module using the `{in}` +/// operator, with a string on the left-hand side. This can be useful to +/// [conditionally access]($category/foundations/std/#conditional-access) +/// definitions in a module. +/// +/// ```example +/// #("table" in std) \ +/// #("nope" in std) +/// ``` +/// +/// Alternatively, it is possible to convert a module to a dictionary, and +/// therefore access its contents dynamically, using the [dictionary +/// constructor]($dictionary/#constructor). #[ty(cast)] #[derive(Clone, Hash)] #[allow(clippy::derived_hash_with_manual_eq)] |
