mirror of
https://github.com/servo/servo.git
synced 2025-07-10 00:43:39 +01:00
Bug 1330824 - Add IndexMut for nsStyleAutoArray. r=heycam
MozReview-Commit-ID: 9EU8g4SLoHp
This commit is contained in:
parent
ce59a7e9ee
commit
2d19e67fc4
1 changed files with 13 additions and 1 deletions
|
@ -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<T> Index<usize> for nsStyleAutoArray<T> {
|
||||
|
@ -23,6 +23,18 @@ impl<T> Index<usize> for nsStyleAutoArray<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> IndexMut<usize> for nsStyleAutoArray<T> {
|
||||
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<T> nsStyleAutoArray<T> {
|
||||
/// Mutably iterate over the array elements.
|
||||
pub fn iter_mut(&mut self) -> Chain<Once<&mut T>, IterMut<T>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue