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