diff --git a/examples/custom_types.rs b/examples/custom_types.rs index eb84992e..3fa7c7ef 100644 --- a/examples/custom_types.rs +++ b/examples/custom_types.rs @@ -49,7 +49,7 @@ fn main() -> Result<(), Box> { .with_fn("new_ts", Self::new) .with_fn("update", Self::update) .with_fn("calc", Self::calculate) - .with_iterator() + .is_iterable() .with_get_set("x", Self::get_x, Self::set_x); } } diff --git a/src/api/build_type.rs b/src/api/build_type.rs index e26c85bc..23199b0b 100644 --- a/src/api/build_type.rs +++ b/src/api/build_type.rs @@ -154,7 +154,7 @@ where /// Register a type iterator. /// This is an advanced API. #[inline(always)] - pub fn with_iterator(&mut self) -> &mut Self { + pub fn is_iterable(&mut self) -> &mut Self { self.engine.register_iterator::(); self } diff --git a/tests/build_type.rs b/tests/build_type.rs index c4f2c3bd..6d21bb9d 100644 --- a/tests/build_type.rs +++ b/tests/build_type.rs @@ -58,8 +58,9 @@ fn build_type() -> Result<(), Box> { fn build(mut builder: TypeBuilder) { builder .with_name("Vec3") + .is_iterable() .with_fn("vec3", Self::new) - .with_iterator() + .is_iterable() .with_get_set("x", Self::get_x, Self::set_x) .with_get_set("y", Self::get_y, Self::set_y) .with_get_set("z", Self::get_z, Self::set_z); @@ -127,6 +128,19 @@ fn build_type() -> Result<(), Box> { )?, Vec3::new(5, 6, 7), ); + assert_eq!( + engine.eval::( + " + let sum = 0; + let v = vec3(1, 2, 3); + for i in v { + sum += i; + } + sum + ", + )?, + 6, + ); Ok(()) }