Begin converting to new built-in API
This commit is contained in:
parent
a1f3dcb107
commit
fc898e28e2
19
src/built_in_functions/assert.rs
Normal file
19
src/built_in_functions/assert.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
use crate::{BuiltInFunction, Error, Result, Value};
|
||||||
|
|
||||||
|
pub struct Assert;
|
||||||
|
|
||||||
|
impl BuiltInFunction for Assert {
|
||||||
|
fn name(&self) -> &'static str {
|
||||||
|
"assert"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(&self, arguments: &[Value]) -> Result<Value> {
|
||||||
|
for argument in arguments {
|
||||||
|
if !argument.as_boolean()? {
|
||||||
|
return Err(Error::AssertFailed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Value::Empty)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user