diff options
Diffstat (limited to 'library/src/compute/foundations.rs')
| -rw-r--r-- | library/src/compute/foundations.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/library/src/compute/foundations.rs b/library/src/compute/foundations.rs index 5134d4ac..abe797dc 100644 --- a/library/src/compute/foundations.rs +++ b/library/src/compute/foundations.rs @@ -5,17 +5,20 @@ use typst::model; use typst::syntax::Source; /// The name of a value's type. -pub fn type_(_: &Vm, args: &mut Args) -> SourceResult<Value> { +#[func] +pub fn type_(args: &mut Args) -> SourceResult<Value> { Ok(args.expect::<Value>("value")?.type_name().into()) } /// The string representation of a value. -pub fn repr(_: &Vm, args: &mut Args) -> SourceResult<Value> { +#[func] +pub fn repr(args: &mut Args) -> SourceResult<Value> { Ok(args.expect::<Value>("value")?.repr().into()) } /// Ensure that a condition is fulfilled. -pub fn assert(_: &Vm, args: &mut Args) -> SourceResult<Value> { +#[func] +pub fn assert(args: &mut Args) -> SourceResult<Value> { let Spanned { v, span } = args.expect::<Spanned<bool>>("condition")?; if !v { bail!(span, "assertion failed"); @@ -24,6 +27,7 @@ pub fn assert(_: &Vm, args: &mut Args) -> SourceResult<Value> { } /// Evaluate a string as Typst markup. +#[func] pub fn eval(vm: &Vm, args: &mut Args) -> SourceResult<Value> { let Spanned { v: text, span } = args.expect::<Spanned<String>>("source")?; let source = Source::synthesized(text, span); |
