diff --git a/ports/geckolib/gecko_bindings/sugar/mod.rs b/ports/geckolib/gecko_bindings/sugar/mod.rs index 17d1e9209c2..9c1e4637249 100644 --- a/ports/geckolib/gecko_bindings/sugar/mod.rs +++ b/ports/geckolib/gecko_bindings/sugar/mod.rs @@ -2,4 +2,5 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +mod ns_style_auto_array; mod ns_t_array; diff --git a/ports/geckolib/gecko_bindings/sugar/ns_style_auto_array.rs b/ports/geckolib/gecko_bindings/sugar/ns_style_auto_array.rs new file mode 100644 index 00000000000..bfcd7dc3cef --- /dev/null +++ b/ports/geckolib/gecko_bindings/sugar/ns_style_auto_array.rs @@ -0,0 +1,21 @@ +use std::iter::{once, Chain, Once, IntoIterator}; +use std::slice::{IterMut}; +use structs::nsStyleAutoArray; + +impl nsStyleAutoArray { + pub fn iter_mut(&mut self) -> Chain, IterMut> { + once(&mut self.mFirstElement).chain(self.mOtherElements.iter_mut()) + } + + pub fn len(&self) -> usize { + 1 + self.mOtherElements.len() + } +} + +impl<'a, T> IntoIterator for &'a mut nsStyleAutoArray { + type Item = &'a mut T; + type IntoIter = Chain, IterMut<'a, T>>; + fn into_iter(self) -> Self::IntoIter { + self.iter_mut() + } +} \ No newline at end of file