|
@@ -716,7 +716,7 @@ impl Data {
|
|
|
}
|
|
|
}
|
|
|
/// Gets like [Data::vec_get] except as mutable
|
|
|
- pub fn get_mut<I>(&mut self, index: I) -> Option<&mut I::Output>
|
|
|
+ pub fn vec_get_mut<I>(&mut self, index: I) -> Option<&mut I::Output>
|
|
|
where
|
|
|
I: SliceIndex<[Data]>,
|
|
|
{
|
|
@@ -725,6 +725,40 @@ impl Data {
|
|
|
_ => None,
|
|
|
}
|
|
|
}
|
|
|
+ pub fn map_contains_key(&self, key: &String) -> bool {
|
|
|
+ match self {
|
|
|
+ Self::Map(hm) => hm.contains_key(key),
|
|
|
+ _ => false,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// Get for a Map, see [HashMap::get]
|
|
|
+ pub fn map_get(&self, key: &String) -> Option<&Data> {
|
|
|
+ match self {
|
|
|
+ Self::Map(hm) => hm.get(key),
|
|
|
+ _ => None
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// Get as mutable for a Map
|
|
|
+ pub fn map_get_mut(&mut self, key: &String) -> Option<&mut Data> {
|
|
|
+ match self {
|
|
|
+ Self::Map(hm) => hm.get_mut(key),
|
|
|
+ _ => None
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// Get Key & Value for a Map
|
|
|
+ pub fn map_get_key_value(&self, key: &String) -> Option<(&String, &Data)> {
|
|
|
+ match self {
|
|
|
+ Self::Map(hm) => hm.get_key_value(key),
|
|
|
+ _ => None
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// Removes for a Map
|
|
|
+ pub fn map_remove(&mut self, key: &String) -> Option<Data> {
|
|
|
+ match self {
|
|
|
+ Self::Map(hm) => hm.remove(key),
|
|
|
+ _ => None
|
|
|
+ }
|
|
|
+ }
|
|
|
/// Swaps a with b in a Vec
|
|
|
pub fn vec_swap(&mut self, a: usize, b: usize) {
|
|
|
if let Self::Vec(v) = self { v.swap(a, b) }
|