Struct liquid_core::Object[][src]

pub struct Object { /* fields omitted */ }

Type representing a Liquid object, payload of the Value::Object variant

Implementations

impl Object[src]

pub fn new() -> Self[src]

Makes a new empty Object.

pub fn clear(&mut self)[src]

Clears the map, removing all values.

pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&Value> where
    KString: Borrow<Q>,
    Q: Ord + Eq + Hash
[src]

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.

pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
    KString: Borrow<Q>,
    Q: Ord + Eq + Hash
[src]

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.

pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut Value> where
    KString: Borrow<Q>,
    Q: Ord + Eq + Hash
[src]

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.

pub fn insert(&mut self, k: KString, v: Value) -> Option<Value>[src]

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.

pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<Value> where
    KString: Borrow<Q>,
    Q: Ord + Eq + Hash
[src]

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.

pub fn entry<S>(&mut self, key: S) -> Entry<'_> where
    S: Into<KString>, 
[src]

Gets the given key's corresponding entry in the map for in-place manipulation.

pub fn len(&self) -> usize[src]

Returns the number of elements in the map.

pub fn is_empty(&self) -> bool[src]

Returns true if the map contains no elements.

pub fn iter(&self) -> Iter<'_>

Notable traits for Iter<'a>

impl<'a> Iterator for Iter<'a> type Item = (&'a KString, &'a Value);
[src]

Gets an iterator over the entries of the map.

pub fn iter_mut(&mut self) -> IterMut<'_>

Notable traits for IterMut<'a>

impl<'a> Iterator for IterMut<'a> type Item = (&'a KString, &'a mut Value);
[src]

Gets a mutable iterator over the entries of the map.

pub fn keys(&self) -> Keys<'_>

Notable traits for Keys<'a>

impl<'a> Iterator for Keys<'a> type Item = &'a KString;
[src]

Gets an iterator over the keys of the map.

pub fn values(&self) -> Values<'_>

Notable traits for Values<'a>

impl<'a> Iterator for Values<'a> type Item = &'a Value;
[src]

Gets an iterator over the values of the map.

pub fn values_mut(&mut self) -> ValuesMut<'_>

Notable traits for ValuesMut<'a>

impl<'a> Iterator for ValuesMut<'a> type Item = &'a mut Value;
[src]

Gets an iterator over mutable values of the map.

Trait Implementations

impl Clone for Object[src]

impl Debug for Object[src]

impl Default for Object[src]

impl<'de> Deserialize<'de> for Object[src]

impl Eq for Object[src]

impl Extend<(KString, Value)> for Object[src]

impl From<Object> for ValueCow<'static>[src]

impl From<Object> for Value[src]

impl FromIterator<(KString, Value)> for Object[src]

impl<'a, Q: ?Sized> Index<&'a Q> for Object where
    KString: Borrow<Q>,
    Q: Ord + Eq + Hash
[src]

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,
}

type Output = Value

The returned type after indexing.

impl<'a, Q: ?Sized> IndexMut<&'a Q> for Object where
    KString: Borrow<Q>,
    Q: Ord + Eq + Hash
[src]

Mutably access an element of this map. Panics if the given key is not present in the map.

map["key"] = liquid_core::value!("value");

impl<'a> IntoIterator for &'a Object[src]

type Item = (&'a KString, &'a Value)

The type of the elements being iterated over.

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a mut Object[src]

type Item = (&'a KString, &'a mut Value)

The type of the elements being iterated over.

type IntoIter = IterMut<'a>

Which kind of iterator are we turning this into?

impl IntoIterator for Object[src]

type Item = (KString, Value)

The type of the elements being iterated over.

type IntoIter = IntoIter

Which kind of iterator are we turning this into?

impl ObjectView for Object[src]

impl PartialEq<Object> for Object[src]

impl Serialize for Object[src]

impl ValueView for Object[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Clone + Any
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.