summaryrefslogtreecommitdiff
path: root/src/eval/value.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-05-26 13:49:44 +0200
committerLaurenz <laurmaedje@gmail.com>2022-05-26 13:49:44 +0200
commita9869c212f7c1bc77a52e301ad014641b014e834 (patch)
tree97b5d6c71940e903482ba2f30cbcedd8f1c17ea3 /src/eval/value.rs
parent66d8f4569a9f13270c5f477e0730f127a22333e2 (diff)
Locatable groups
Diffstat (limited to 'src/eval/value.rs')
-rw-r--r--src/eval/value.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/eval/value.rs b/src/eval/value.rs
index b47d1e91..9b36812a 100644
--- a/src/eval/value.rs
+++ b/src/eval/value.rs
@@ -11,7 +11,7 @@ use crate::geom::{
Angle, Color, Dir, Em, Fraction, Length, Paint, Ratio, Relative, RgbaColor, Sides,
};
use crate::library::text::RawNode;
-use crate::model::{Content, Layout, LayoutNode, Pattern};
+use crate::model::{Content, Group, Layout, LayoutNode, Pattern};
use crate::syntax::Spanned;
use crate::util::EcoString;
@@ -73,6 +73,14 @@ impl Value {
Self::Content(Content::block(node))
}
+ /// Create a new dynamic value.
+ pub fn dynamic<T>(any: T) -> Self
+ where
+ T: Type + Debug + PartialEq + Hash + Sync + Send + 'static,
+ {
+ Self::Dyn(Dynamic::new(any))
+ }
+
/// The name of the stored value's type.
pub fn type_name(&self) -> &'static str {
match self {
@@ -653,6 +661,10 @@ dynamic! {
Regex: "regular expression",
}
+dynamic! {
+ Group: "group",
+}
+
castable! {
usize,
Expected: "non-negative integer",