pub enum Value {
Null,
Boolean(bool),
Number(f64),
String(String),
List(Vec<Value>),
Map(BTreeMap<String, Value>),
}
Expand description
Represents any value.
Variants§
Null
Represents the absence of a value.
Boolean(bool)
Represents true
or false
.
Number(f64)
Represents any number.
String(String)
Represents any string of characters.
List(Vec<Value>)
Represents any sequence of values.
Map(BTreeMap<String, Value>)
Represents any mapping from strings to values.
Implementations§
source§impl Value
impl Value
sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Returns true
if this Value
represents a boolean.
source§impl Value
impl Value
sourcepub fn as_null(&self) -> Option<()>
pub fn as_null(&self) -> Option<()>
Returns Some
if this Value
represents a null value, otherwise returns None
.
sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
Returns the underlying boolean, if that’s what this Value
represents.
sourcepub fn as_number(&self) -> Option<f64>
pub fn as_number(&self) -> Option<f64>
Returns the underlying number, if that’s what this Value
represents.
sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns a reference to the underlying string, if that’s what this Value
represents.
source§impl Value
impl Value
sourcepub fn into_string(self) -> Result<String, Self>
pub fn into_string(self) -> Result<String, Self>
If the Value
represented a string it is returned in the Ok
result, else the Value
is preserved in the Err
result.
Trait Implementations§
source§impl<V: Into<Value>> FromIterator<V> for Value
impl<V: Into<Value>> FromIterator<V> for Value
source§fn from_iter<T: IntoIterator<Item = V>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = V>>(iter: T) -> Self
Creates a value from an iterator. Read more
source§impl PartialEq for Value
impl PartialEq for Value
source§impl PartialOrd for Value
impl PartialOrd for Value
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl StructuralPartialEq for Value
Auto Trait Implementations§
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin 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
Mutably borrows from an owned value. Read more