pub struct OccupiedEntry<'a> { /* private fields */ }Expand description
An occupied Entry. It is part of the Entry enum.
Implementations§
Source§impl<'a> OccupiedEntry<'a>
impl<'a> OccupiedEntry<'a>
Sourcepub fn key(&self) -> &Cow<'static, str>
pub fn key(&self) -> &Cow<'static, str>
Gets a reference to the key in the entry.
§Examples
use liquid_value::map::Entry;
let mut map = liquid_value::map::Map::new();
map.insert("liquid".into(), liquid_value!(12));
match map.entry("liquid") {
Entry::Occupied(occupied) => {
assert_eq!(occupied.key(), &"liquid");
}
Entry::Vacant(_) => unimplemented!(),
}Sourcepub fn get(&self) -> &Value
pub fn get(&self) -> &Value
Gets a reference to the value in the entry.
§Examples
use liquid_value::map::Entry;
let mut map = liquid_value::map::Map::new();
map.insert("liquid".into(), liquid_value!(12));
match map.entry("liquid") {
Entry::Occupied(occupied) => {
assert_eq!(occupied.get(), &liquid_value!(12));
}
Entry::Vacant(_) => unimplemented!(),
}Sourcepub fn get_mut(&mut self) -> &mut Value
pub fn get_mut(&mut self) -> &mut Value
Gets a mutable reference to the value in the entry.
§Examples
use liquid_value::map::Entry;
let mut map = liquid_value::map::Map::new();
map.insert("liquid".into(), liquid_value!([1, 2, 3]));
match map.entry("liquid") {
Entry::Occupied(mut occupied) => {
occupied.get_mut().as_array_mut().unwrap().push(liquid_value!(4));
}
Entry::Vacant(_) => unimplemented!(),
}
assert_eq!(map["liquid"].as_array().unwrap().len(), 4);Sourcepub fn into_mut(self) -> &'a mut Value
pub fn into_mut(self) -> &'a mut Value
Converts the entry into a mutable reference to its value.
§Examples
use liquid_value::map::Entry;
let mut map = liquid_value::map::Map::new();
map.insert("liquid".into(), liquid_value!([1, 2, 3]));
match map.entry("liquid") {
Entry::Occupied(mut occupied) => {
occupied.into_mut().as_array_mut().unwrap().push(liquid_value!(4));
}
Entry::Vacant(_) => unimplemented!(),
}
assert_eq!(map["liquid"].as_array().unwrap().len(), 4);Sourcepub fn insert(&mut self, value: Value) -> Value
pub fn insert(&mut self, value: Value) -> Value
Sets the value of the entry with the OccupiedEntry’s key, and returns
the entry’s old value.
§Examples
use liquid_value::map::Entry;
let mut map = liquid_value::map::Map::new();
map.insert("liquid".into(), liquid_value!(12));
match map.entry("liquid") {
Entry::Occupied(mut occupied) => {
assert_eq!(occupied.insert(liquid_value!(13)), liquid_value!(12));
assert_eq!(occupied.get(), &liquid_value!(13));
}
Entry::Vacant(_) => unimplemented!(),
}Sourcepub fn remove(self) -> Value
pub fn remove(self) -> Value
Takes the value of the entry out of the map, and returns it.
§Examples
use liquid_value::map::Entry;
let mut map = liquid_value::map::Map::new();
map.insert("liquid".into(), liquid_value!(12));
match map.entry("liquid") {
Entry::Occupied(occupied) => {
assert_eq!(occupied.remove(), liquid_value!(12));
}
Entry::Vacant(_) => unimplemented!(),
}Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for OccupiedEntry<'a>
impl<'a> RefUnwindSafe for OccupiedEntry<'a>
impl<'a> Send for OccupiedEntry<'a>
impl<'a> Sync for OccupiedEntry<'a>
impl<'a> Unpin for OccupiedEntry<'a>
impl<'a> !UnwindSafe for OccupiedEntry<'a>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more