pub enum Value {
Null,
Bool(bool),
Number(Number),
String(String),
Array(Vec<Spanned<Value>>),
Object(Map<Spanned<String>, Spanned<Value>>),
}
Expand description
A basic un-Spanned value, with Spanned children.
Unless you want to match
it, you probably want spanned::Value.
Variants§
Null
null
Bool(bool)
true
or false
Number(Number)
A number like 123
String(String)
A string like "asdf"
Array(Vec<Spanned<Value>>)
An array like [1, 2, 3]
Object(Map<Spanned<String>, Spanned<Value>>)
An object like {"a": 1, "b": 2}
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_array(&self) -> Option<&Vec<Spanned<Value>>>
pub fn as_array(&self) -> Option<&Vec<Spanned<Value>>>
Some(&inner)
if self is an array like [1, 2, 3]
Sourcepub fn as_object(&self) -> Option<&Map<Spanned<String>, Spanned<Value>>>
pub fn as_object(&self) -> Option<&Map<Spanned<String>, Spanned<Value>>>
Some(&inner)
if self is an object like {"a": 1, "b": 2}
Sourcepub fn as_bool_mut(&mut self) -> Option<&mut bool>
pub fn as_bool_mut(&mut self) -> Option<&mut bool>
Some(&mut v)
if self is true
or false
Sourcepub fn as_number_mut(&mut self) -> Option<&mut Number>
pub fn as_number_mut(&mut self) -> Option<&mut Number>
Some(&mut v)
if self is a number like 123
Sourcepub fn as_string_mut(&mut self) -> Option<&mut String>
pub fn as_string_mut(&mut self) -> Option<&mut String>
Some(&mut v)
if self is a string like "asdf"
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Vec<Spanned<Value>>>
pub fn as_array_mut(&mut self) -> Option<&mut Vec<Spanned<Value>>>
Some(&mut v)
if self is an array like [1, 2, 3]
Sourcepub fn as_object_mut(
&mut self,
) -> Option<&mut Map<Spanned<String>, Spanned<Value>>>
pub fn as_object_mut( &mut self, ) -> Option<&mut Map<Spanned<String>, Spanned<Value>>>
Some(&mut v)
if self is an object like {"a": 1, "b": 2}
Sourcepub fn into_bool(self) -> Result<bool, Self>
pub fn into_bool(self) -> Result<bool, Self>
Ok(inner)
if self is true
or false
, otherwise Err(self)
Sourcepub fn into_number(self) -> Result<Number, Self>
pub fn into_number(self) -> Result<Number, Self>
Ok(inner)
if self is a number like 123
, otherwise Err(self)
Sourcepub fn into_string(self) -> Result<String, Self>
pub fn into_string(self) -> Result<String, Self>
Ok(inner)
if self is a string like "asdf"
, otherwise Err(self)
Sourcepub fn into_array(self) -> Result<Vec<Spanned<Value>>, Self>
pub fn into_array(self) -> Result<Vec<Spanned<Value>>, Self>
Ok(inner)
if self is an array like [1, 2, 3]
, otherwise Err(self)