pub struct Any;Expand description
Function that checks whether any of array items satisfy the provided predicate.
§Type
(using arithmetic-typing notation)
(['T], ('T) -> Bool) -> Bool§Examples
let program = "
assert(any((1, 3, -1), |x| x < 0));
assert(!any((1, 2, 3), |x| x < 0));
";
let program = Untyped::<F32Grammar>::parse_statements(program)?;
let module = ExecutableModule::new("test_any", &program)?;
let mut env = Environment::new();
env.insert_native_fn("any", fns::Any)
.insert_native_fn("assert", fns::Assert);
module.with_env(&env)?.run()?;Trait Implementations§
impl Copy for Any
Source§impl<T: Clone + 'static> NativeFn<T> for Any
impl<T: Clone + 'static> NativeFn<T> for Any
Source§fn evaluate(
&self,
args: Vec<SpannedValue<T>>,
ctx: &mut CallContext<'_, T>,
) -> EvalResult<T>
fn evaluate( &self, args: Vec<SpannedValue<T>>, ctx: &mut CallContext<'_, T>, ) -> EvalResult<T>
Executes the function on the specified arguments.
Auto Trait Implementations§
impl Freeze for Any
impl RefUnwindSafe for Any
impl Send for Any
impl Sync for Any
impl Unpin for Any
impl UnsafeUnpin for Any
impl UnwindSafe for Any
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more