1use std::ops::{Index, IndexMut};
2
3use crate::Value;
4
5impl<'a, I: Into<crate::ValueKey<'a>>> Index<I> for Value {
6 type Output = Value;
7
8 fn index(&self, index: I) -> &Value {
9 self.get(index)
10 .expect("value should be an array or map containing the given key")
11 }
12}
13
14impl<'a, I: Into<crate::ValueKey<'a>>> IndexMut<I> for Value {
15 fn index_mut(&mut self, index: I) -> &mut Value {
16 self.get_mut(index)
17 .expect("value should be an array or map containing the given key")
18 }
19}