Skip to main content

nanvm_lib/vm/impls/
into_iterator.rs

1use crate::{
2    common::{index_iter::IndexIter, sized_index::SizedIndex},
3    vm::{Any, Array, IVm, Object, Property, String},
4};
5
6type Iter<T> = IndexIter<u32, T>;
7
8impl<A: IVm> IntoIterator for Array<A> {
9    type Item = Any<A>;
10    type IntoIter = Iter<Array<A>>;
11    fn into_iter(self) -> Self::IntoIter {
12        self.index_iter()
13    }
14}
15
16impl<A: IVm> IntoIterator for Object<A> {
17    type Item = Property<A>;
18    type IntoIter = Iter<Object<A>>;
19    fn into_iter(self) -> Self::IntoIter {
20        self.index_iter()
21    }
22}
23
24impl<A: IVm> IntoIterator for String<A> {
25    type Item = u16;
26    type IntoIter = Iter<String<A>>;
27    fn into_iter(self) -> Self::IntoIter {
28        self.index_iter()
29    }
30}