nanvm_lib/vm/string/index.rs
1use core::ops::Index;
2
3use crate::vm::{ContainerWrapper, IVm, String};
4
5impl<A: IVm> Index<u32> for String<A> {
6 type Output = u16;
7 /// Currently panics if out of bounds.
8 /// TODO: Future versions may change to return `Result<u16, Any<A>>`.
9 /// Also we can implement `Index<Any<A>>`, `Index<f64>` and `Index<String16>`.
10 fn index(&self, index: u32) -> &Self::Output {
11 self.item(index)
12 }
13}
14
15impl<A: IVm> ContainerWrapper for String<A> {
16 type Vm = A;
17 type Internal = A::InternalString;
18 fn internal(&self) -> &Self::Internal {
19 &self.0
20 }
21}