Skip to main content

nanvm_lib/vm/array/
index.rs

1use core::ops::Index;
2
3use crate::vm::{Any, Array, ContainerWrapper, IVm};
4
5impl<A: IVm> Index<u32> for Array<A> {
6    type Output = Any<A>;
7    /// Currently panics if out of bounds.
8    /// TODO: Future versions may change to return `Nullish::Undefined`.
9    fn index(&self, index: u32) -> &Self::Output {
10        self.item(index)
11    }
12}
13
14impl<A: IVm> ContainerWrapper for Array<A> {
15    type Vm = A;
16    type Internal = A::InternalArray;
17    fn internal(&self) -> &Self::Internal {
18        &self.0
19    }
20}