MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / any

Function any

aiscript-vm/src/builtins/mod.rs:154–170  ·  view source on GitHub ↗
(_state: &mut State<'gc>, args: Vec<Value<'gc>>)

Source from the content-addressed store, hash-verified

152}
153
154fn any<'gc>(_state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> {
155 if args.len() != 1 {
156 return Err(VmError::RuntimeError(
157 "any() takes exactly one argument.".into(),
158 ));
159 }
160
161 match &args[0] {
162 Value::List(arr) => {
163 let arr = &arr.borrow().data;
164 Ok(Value::Boolean(arr.iter().any(|x| x.is_true())))
165 }
166 _ => Err(VmError::RuntimeError(
167 "any() argument must be an array.".into(),
168 )),
169 }
170}
171
172fn all<'gc>(_state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> {
173 if args.len() != 1 {

Callers

nothing calls this directly

Calls 4

RuntimeErrorClass · 0.85
lenMethod · 0.80
is_trueMethod · 0.80
borrowMethod · 0.45

Tested by

no test coverage detected