MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / bool_id_check

Function bool_id_check

nodedb-query/src/functions/shared.rs:25–29  ·  view source on GitHub ↗

Check if the first arg is a string matching a predicate.

(args: &[Value], check: impl Fn(&str) -> bool)

Source from the content-addressed store, hash-verified

23
24/// Check if the first arg is a string matching a predicate.
25pub 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}

Callers 1

try_evalFunction · 0.85

Calls 3

firstMethod · 0.80
checkFunction · 0.50
as_strMethod · 0.45

Tested by

no test coverage detected