mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Add iterators for nsStyleAutoArray
This commit is contained in:
parent
b1a3831bf6
commit
3a5a56807a
2 changed files with 22 additions and 0 deletions
|
@ -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;
|
||||
|
|
21
ports/geckolib/gecko_bindings/sugar/ns_style_auto_array.rs
Normal file
21
ports/geckolib/gecko_bindings/sugar/ns_style_auto_array.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
use std::iter::{once, Chain, Once, IntoIterator};
|
||||
use std::slice::{IterMut};
|
||||
use structs::nsStyleAutoArray;
|
||||
|
||||
impl<T> nsStyleAutoArray<T> {
|
||||
pub fn iter_mut(&mut self) -> Chain<Once<&mut T>, IterMut<T>> {
|
||||
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<T> {
|
||||
type Item = &'a mut T;
|
||||
type IntoIter = Chain<Once<&'a mut T>, IterMut<'a, T>>;
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.iter_mut()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue