Skip to main content

surrealdb_expr/val/value/
flatten.rs

1use crate::val::{Array, Value};
2
3impl Value {
4	pub fn flatten(self) -> Self {
5		match self {
6			Value::Array(v) => {
7				let mut res = Vec::with_capacity(v.len());
8
9				for v in v {
10					match v {
11						Value::Array(x) => {
12							for x in x {
13								res.push(x);
14							}
15						}
16						x => res.push(x),
17					}
18				}
19
20				Value::Array(Array(res))
21			}
22			v => v,
23		}
24	}
25}