surrealdb_core/sql/value/
clear.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::err::Error;
use crate::sql::value::Value;

impl Value {
	pub fn clear(&mut self) -> Result<(), Error> {
		*self = Value::None;
		Ok(())
	}
}

#[cfg(test)]
mod tests {

	use super::*;
	use crate::syn::Parse;

	#[tokio::test]
	async fn clear_value() {
		let mut val = Value::parse("{ test: { other: null, something: 123 } }");
		let res = Value::None;
		val.clear().unwrap();
		assert_eq!(res, val);
	}
}