Check if the first arg is a string matching a predicate.
(args: &[Value], check: impl Fn(&str) -> bool)
| 23 | |
| 24 | /// Check if the first arg is a string matching a predicate. |
| 25 | pub fn bool_id_check(args: &[Value], check: impl Fn(&str) -> bool) -> Value { |
| 26 | args.first() |
| 27 | .and_then(|v| v.as_str()) |
| 28 | .map_or(Value::Bool(false), |s| Value::Bool(check(s))) |
| 29 | } |