pub enum Value {
Null,
Bool(bool),
Num(f64),
Str(String),
List(Vec<Value>),
Obj(BTreeMap<String, Value>),
}Expand description
A value the dialect computes over.
There is one numeric type, f64: every numeric literal and every JSON number widens to it, so
42 and 42.0 are the same value. The derived PartialEq is structural (for tests and round
trips); the dialect’s own == — null == null, true != 1, NaN never equal — is
Value::dialect_eq.
Variants§
Null
Absent / unknown. Propagates through arithmetic and most functions.
Bool(bool)
A boolean — distinct from numbers: true == 1 is false.
Num(f64)
A number (always f64).
Str(String)
A string.
List(Vec<Value>)
A list of values.
Obj(BTreeMap<String, Value>)
A string-keyed object.
Implementations§
Source§impl Value
impl Value
Sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
The dialect’s name for this value’s type: null, boolean, number, string, list
or object (what the typeOf function returns).
Sourcepub fn dialect_eq(&self, other: &Value) -> bool
pub fn dialect_eq(&self, other: &Value) -> bool
The dialect’s ==: null == null is true; a boolean equals only the same boolean; any
other comparison involving null is false; numbers compare by value (so NaN is never equal);
lists and objects compare element-wise with these same rules.
Trait Implementations§
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more