Struct liquid_core::model::map::Object
source · pub struct Object { /* private fields */ }
Expand description
Type representing a Liquid object, payload of the Value::Object
variant
Implementations§
source§impl Object
impl Object
sourcepub fn get<Q>(&self, key: &Q) -> Option<&Value>where
KString: Borrow<Q>,
Q: Ord + Eq + Hash + ?Sized,
pub fn get<Q>(&self, key: &Q) -> Option<&Value>where KString: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,
Returns a reference to the value corresponding to the key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
sourcepub fn contains_key<Q>(&self, key: &Q) -> boolwhere
KString: Borrow<Q>,
Q: Ord + Eq + Hash + ?Sized,
pub fn contains_key<Q>(&self, key: &Q) -> boolwhere KString: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,
Returns true if the map contains a value for the specified key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Value>where
KString: Borrow<Q>,
Q: Ord + Eq + Hash + ?Sized,
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut Value>where KString: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,
Returns a mutable reference to the value corresponding to the key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
sourcepub fn insert(&mut self, k: KString, v: Value) -> Option<Value>
pub fn insert(&mut self, k: KString, v: Value) -> Option<Value>
Inserts a key-value pair into the map.
If the map did not have this key present, None
is returned.
If the map did have this key present, the value is updated, and the old value is returned.
sourcepub fn remove<Q>(&mut self, key: &Q) -> Option<Value>where
KString: Borrow<Q>,
Q: Ord + Eq + Hash + ?Sized,
pub fn remove<Q>(&mut self, key: &Q) -> Option<Value>where KString: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,
Removes a key from the map, returning the value at the key if the key was previously in the map.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
sourcepub fn entry<S>(&mut self, key: S) -> Entry<'_>where
S: Into<KString>,
pub fn entry<S>(&mut self, key: S) -> Entry<'_>where S: Into<KString>,
Gets the given key’s corresponding entry in the map for in-place manipulation.
sourcepub fn iter_mut(&mut self) -> IterMut<'_> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_> ⓘ
Gets a mutable iterator over the entries of the map.
sourcepub fn values_mut(&mut self) -> ValuesMut<'_> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_> ⓘ
Gets an iterator over mutable values of the map.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Object
impl<'de> Deserialize<'de> for Object
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
source§impl Extend<(KStringBase<Box<str, Global>>, Value)> for Object
impl Extend<(KStringBase<Box<str, Global>>, Value)> for Object
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = (KString, Value)>,
fn extend<T>(&mut self, iter: T)where T: IntoIterator<Item = (KString, Value)>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl FromIterator<(KStringBase<Box<str, Global>>, Value)> for Object
impl FromIterator<(KStringBase<Box<str, Global>>, Value)> for Object
source§impl<'a, Q> Index<&'a Q> for Objectwhere
KString: Borrow<Q>,
Q: Ord + Eq + Hash + ?Sized,
impl<'a, Q> Index<&'a Q> for Objectwhere KString: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,
Access an element of this map. Panics if the given key is not present in the map.
match *val {
Value::Scalar(ref s) => Some(s.to_kstr()),
Value::Array(ref arr) => Some(arr[0].to_kstr()),
Value::Object(ref map) => Some(map["type"].to_kstr()),
_ => None,
}
source§impl<'a, Q> IndexMut<&'a Q> for Objectwhere
KString: Borrow<Q>,
Q: Ord + Eq + Hash + ?Sized,
impl<'a, Q> IndexMut<&'a Q> for Objectwhere KString: Borrow<Q>, Q: Ord + Eq + Hash + ?Sized,
Mutably access an element of this map. Panics if the given key is not present in the map.
map["key"] = liquid_core::value!("value");
source§impl<'a> IntoIterator for &'a Object
impl<'a> IntoIterator for &'a Object
source§impl<'a> IntoIterator for &'a mut Object
impl<'a> IntoIterator for &'a mut Object
source§impl IntoIterator for Object
impl IntoIterator for Object
source§impl ObjectView for Object
impl ObjectView for Object
source§fn keys<'k>(&'k self) -> Box<dyn Iterator<Item = KStringCow<'k>> + 'k>
fn keys<'k>(&'k self) -> Box<dyn Iterator<Item = KStringCow<'k>> + 'k>
source§fn values<'k>(&'k self) -> Box<dyn Iterator<Item = &'k dyn ValueView> + 'k>
fn values<'k>(&'k self) -> Box<dyn Iterator<Item = &'k dyn ValueView> + 'k>
source§fn iter<'k>(
&'k self
) -> Box<dyn Iterator<Item = (KStringCow<'k>, &'k dyn ValueView)> + 'k>
fn iter<'k>( &'k self ) -> Box<dyn Iterator<Item = (KStringCow<'k>, &'k dyn ValueView)> + 'k>
source§fn contains_key(&self, index: &str) -> bool
fn contains_key(&self, index: &str) -> bool
BoxedValue
.source§impl PartialEq<Object> for Object
impl PartialEq<Object> for Object
source§impl ValueView for Object
impl ValueView for Object
source§fn render(&self) -> DisplayCow<'_>
fn render(&self) -> DisplayCow<'_>
Display
for a BoxedValue
rendered for the user.source§fn source(&self) -> DisplayCow<'_>
fn source(&self) -> DisplayCow<'_>
Display
for a Value
as source code.