#[non_exhaustive]pub enum Value {
Null,
Undefined,
Bool(bool),
Integer(i64),
Float(f64),
String(String),
List(Vec<Value>),
Map(Map),
Date(Date),
DateTime(DateTime),
Duration(Duration),
}Expand description
A predicator value.
Null and Undefined are both values and neither is the other:
undefined is an absence (no value was ever supplied), null is a value
that is present and empty. An integer is an i64; a float an f64.
Equality (==) is strict: two values are equal when they are the same
kind and the same value, so Integer(1) and Float(1.0) are not equal,
two instants are equal when they are the same instant, and lists and
maps are equal member by member. Ordering (partial_cmp) agrees with
it: integers and floats order by number (an integer and a float at the
same number are unordered, being unequal), strings by codepoint, false
before true, dates and instants chronologically, lists member by
member with a proper prefix first; two maps, two durations or two values
of other kinds are unordered unless equal. The compare instruction’s
own rules are the evaluator’s, not these.
Equality, ordering, cloning, Debug and dropping walk a value without
recursion, so a value nested deeper than the stack is compared, copied,
printed and dropped without exhausting it. Because Value implements
Drop, a member is taken out of a value with core::mem::replace
rather than moved out of a pattern.
use predicator_rs::Value;
let list = Value::from(vec![Value::from(1), Value::from("x"), Value::Null]);
assert_eq!(list, Value::List(vec![1.into(), "x".into(), Value::Null]));
assert_ne!(Value::from(1), Value::from(1.0));
assert!(Value::from(1) < Value::from(1.5));
assert_ne!(Value::Null, Value::Undefined);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Null
A value that is present and empty.
Undefined
An absence: no value was ever supplied.
Bool(bool)
true or false.
Integer(i64)
An integer.
Float(f64)
A float.
String(String)
A string.
List(Vec<Value>)
A list.
Map(Map)
A map from Keys.
Date(Date)
A civil date.
DateTime(DateTime)
An instant in UTC.
Duration(Duration)
A duration.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Value, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Value, D::Error>
Reads a value in the tagged encoding.