surrealdb-core 3.2.3

A scalable, distributed, collaborative, document-graph database, for the realtime web
Documentation
use crate::val::{Array, Value};

impl Value {
	pub fn flatten(self) -> Self {
		match self {
			Value::Array(v) => {
				let mut res = Vec::with_capacity(v.len());

				for v in v {
					match v {
						Value::Array(x) => {
							for x in x {
								res.push(x);
							}
						}
						x => res.push(x),
					}
				}

				Value::Array(Array(res))
			}
			v => v,
		}
	}
}