diff --git a/components/style/gecko_bindings/sugar/ns_style_auto_array.rs b/components/style/gecko_bindings/sugar/ns_style_auto_array.rs index 5730382d7d14..4ef12625d2d0 100644 --- a/components/style/gecko_bindings/sugar/ns_style_auto_array.rs +++ b/components/style/gecko_bindings/sugar/ns_style_auto_array.rs @@ -6,8 +6,22 @@ use gecko_bindings::structs::nsStyleAutoArray; use std::iter::{once, Chain, Once, IntoIterator}; +use std::ops::Index; use std::slice::{Iter, IterMut}; +impl Index for nsStyleAutoArray { + type Output = T; + fn index(&self, index: usize) -> &T { + if index > self.len() { + panic!("out of range") + } + match index { + 0 => &self.mFirstElement, + _ => &self.mOtherElements[index - 1], + } + } +} + impl nsStyleAutoArray { /// Mutably iterate over the array elements. pub fn iter_mut(&mut self) -> Chain, IterMut> {