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 9c41a0b6ec4..b20ee735631 100644 --- a/components/style/gecko_bindings/sugar/ns_style_auto_array.rs +++ b/components/style/gecko_bindings/sugar/ns_style_auto_array.rs @@ -7,7 +7,7 @@ use gecko_bindings::bindings::Gecko_EnsureStyleAnimationArrayLength; use gecko_bindings::structs::nsStyleAutoArray; use std::iter::{once, Chain, Once, IntoIterator}; -use std::ops::Index; +use std::ops::{Index, IndexMut}; use std::slice::{Iter, IterMut}; impl Index for nsStyleAutoArray { @@ -23,6 +23,18 @@ impl Index for nsStyleAutoArray { } } +impl IndexMut for nsStyleAutoArray { + fn index_mut(&mut self, index: usize) -> &mut T { + if index > self.len() { + panic!("out of range") + } + match index { + 0 => &mut self.mFirstElement, + _ => &mut self.mOtherElements[index - 1], + } + } +} + impl nsStyleAutoArray { /// Mutably iterate over the array elements. pub fn iter_mut(&mut self) -> Chain, IterMut> {