pub enum Val {
Null,
Bool(bool),
Int(i64),
Float(f64),
Str(Arc<str>),
Arr(Arc<Vec<Val>>),
Obj(Arc<IndexMap<Arc<str>, Val>>),
}Variants§
Null
Bool(bool)
Int(i64)
Float(f64)
Str(Arc<str>)
Arr(Arc<Vec<Val>>)
Obj(Arc<IndexMap<Arc<str>, Val>>)
Implementations§
Source§impl Val
impl Val
Sourcepub fn get_field(&self, key: &str) -> Val
pub fn get_field(&self, key: &str) -> Val
O(1) field lookup — returns a clone of the child (cheap: Arc bump for Arr/Obj, copy for scalars).
Sourcepub fn get_index(&self, i: i64) -> Val
pub fn get_index(&self, i: i64) -> Val
O(1) index — returns a clone of the element (cheap: Arc bump for Arr/Obj).
pub fn is_null(&self) -> bool
pub fn is_bool(&self) -> bool
pub fn is_number(&self) -> bool
pub fn is_string(&self) -> bool
pub fn is_array(&self) -> bool
pub fn is_object(&self) -> bool
pub fn as_bool(&self) -> Option<bool>
pub fn as_i64(&self) -> Option<i64>
pub fn as_f64(&self) -> Option<f64>
pub fn as_str(&self) -> Option<&str>
pub fn as_array(&self) -> Option<&[Val]>
pub fn as_array_mut(&mut self) -> Option<&mut Vec<Val>>
pub fn as_object(&self) -> Option<&IndexMap<Arc<str>, Val>>
pub fn as_object_mut(&mut self) -> Option<&mut IndexMap<Arc<str>, Val>>
pub fn type_name(&self) -> &'static str
Sourcepub fn into_vec(self) -> Option<Vec<Val>>
pub fn into_vec(self) -> Option<Vec<Val>>
Consume self and produce a mutable Vec (clone only if shared).
Sourcepub fn into_map(self) -> Option<IndexMap<Arc<str>, Val>>
pub fn into_map(self) -> Option<IndexMap<Arc<str>, Val>>
Consume self and produce a mutable map (clone only if shared).
Trait Implementations§
impl Eq for Val
Auto Trait Implementations§
impl Freeze for Val
impl RefUnwindSafe for Val
impl Send for Val
impl Sync for Val
impl Unpin for Val
impl UnsafeUnpin for Val
impl UnwindSafe for Val
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.