oneline_template/functions/bool/
unwrap_or.rs1use crate::function_executor::*;
2
3pub struct UnwrapOr;
11
12impl FunctionExecutor for UnwrapOr {
13 fn schema(&self) -> FunctionSchema {
14 FunctionSchema::new("bool:unwrap_or")
15 .with_argument(FunctionArgument::bool())
16 }
17
18 fn call(&self, value: Value, arguments: &[Value]) -> Result<Value, FunctionError> {
19 let value = value.into_option()?;
20 let value = match value {
21 Some(value) => {
22 value.into_bool()?
23 },
24 None => {
25 arguments[0].as_bool()?.clone()
26 },
27 };
28 let value = Value::Bool(value);
29 return Ok(value);
30 }
31}