diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-05-03 16:59:13 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-05-04 00:14:31 +0200 |
| commit | 507c5fc92563560426db0d86c0348880b0493467 (patch) | |
| tree | 45116b62fb0fffe8e88d6c96ae1fcf11c73f8ee9 /src/eval/methods.rs | |
| parent | e18a896a93cae987aa30addd40e678bf0064fd31 (diff) | |
Text replacement show rules
Diffstat (limited to 'src/eval/methods.rs')
| -rw-r--r-- | src/eval/methods.rs | 16 |
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()?, }; |
