summaryrefslogtreecommitdiff
path: root/src/eval/methods.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval/methods.rs')
-rw-r--r--src/eval/methods.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/eval/methods.rs b/src/eval/methods.rs
index b3674dff..363474fb 100644
--- a/src/eval/methods.rs
+++ b/src/eval/methods.rs
@@ -1,8 +1,9 @@
//! Methods on values.
-use super::{Args, StrExt, Value};
+use super::{Args, Regex, StrExt, Value};
use crate::diag::{At, TypResult};
use crate::syntax::Span;
+use crate::util::EcoString;
use crate::Context;
/// Call a method on a value.
@@ -66,6 +67,19 @@ pub fn call(
_ => missing()?,
},
+ Value::Dyn(dynamic) => {
+ if let Some(regex) = dynamic.downcast::<Regex>() {
+ match method {
+ "matches" => {
+ Value::Bool(regex.matches(&args.expect::<EcoString>("text")?))
+ }
+ _ => missing()?,
+ }
+ } else {
+ missing()?
+ }
+ }
+
_ => missing()?,
};