jsonlogic 0.1.2

A JsonLogic implementation in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use serde_json::Value;

use super::logic;

/// Takes an arbitrary number of arguments. Returns the first truthy argument or the last
/// argument.
pub fn compute(args: &[Value]) -> Value {
    for arg in args {
        if logic::is_truthy(arg) {
            return arg.clone();
        }
    }

    args.last().cloned().unwrap_or(Value::Null)
}