surrealdb_core/sql/value/
flatten.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use crate::sql::array::Array;
use crate::sql::value::Value;

impl Value {
	pub fn flatten(self) -> Self {
		match self {
			Value::Array(v) => {
				v.0.into_iter()
					.flat_map(|v| match v {
						Value::Array(v) => v,
						_ => Array::from(v),
					})
					.collect::<Vec<_>>()
					.into()
			}
			v => v,
		}
	}
}