diff options
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/content.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/model/content.rs b/src/model/content.rs index be737331..012ad05f 100644 --- a/src/model/content.rs +++ b/src/model/content.rs @@ -10,7 +10,9 @@ use once_cell::sync::Lazy; use super::{node, Guard, Recipe, Style, StyleMap}; use crate::diag::{SourceResult, StrResult}; -use crate::eval::{cast_from_value, Args, Cast, FuncInfo, Str, Value, Vm}; +use crate::eval::{ + cast_from_value, cast_to_value, Args, Cast, Func, FuncInfo, Str, Value, Vm, +}; use crate::syntax::Span; use crate::util::pretty_array_like; use crate::World; @@ -382,6 +384,15 @@ impl Deref for NodeId { } } +cast_from_value! { + NodeId, + v: Func => v.id().ok_or("this function is not an element")? +} + +cast_to_value! { + v: NodeId => Value::Func(v.into()) +} + /// Static node for a node. pub struct NodeMeta { /// The node's name. |
