use std::slice::Iter as SliceIter;
use serde_json::Value;
use serde_json::map::Iter as MapIter;
pub(in crate::json) enum JsonChildren<'a> {
Array(
SliceIter<'a, Value>,
usize,
),
Object(
MapIter<'a>,
usize,
),
}
impl<'a> JsonChildren<'a> {
#[inline]
pub(in crate::json) fn next(&mut self) -> Option<(Option<&'a str>, &'a Value, usize)> {
match self {
Self::Array(values, depth) => values.next().map(|value| (None, value, *depth)),
Self::Object(values, depth) => values
.next()
.map(|(key, value)| (Some(key.as_str()), value, *depth)),
}
}
}