mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Document sugar for nsStyleAutoArray.
This commit is contained in:
parent
89f3e34f48
commit
1bd246905c
1 changed files with 9 additions and 3 deletions
|
@ -2,21 +2,27 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
//! Rust helpers for Gecko's `nsStyleAutoArray`.
|
||||||
|
|
||||||
use gecko_bindings::structs::nsStyleAutoArray;
|
use gecko_bindings::structs::nsStyleAutoArray;
|
||||||
use std::iter::{once, Chain, Once, IntoIterator};
|
use std::iter::{once, Chain, Once, IntoIterator};
|
||||||
use std::slice::{Iter, IterMut};
|
use std::slice::{Iter, IterMut};
|
||||||
|
|
||||||
impl<T> nsStyleAutoArray<T> {
|
impl<T> nsStyleAutoArray<T> {
|
||||||
|
/// Mutably iterate over the array elements.
|
||||||
pub fn iter_mut(&mut self) -> Chain<Once<&mut T>, IterMut<T>> {
|
pub fn iter_mut(&mut self) -> Chain<Once<&mut T>, IterMut<T>> {
|
||||||
once(&mut self.mFirstElement).chain(self.mOtherElements.iter_mut())
|
once(&mut self.mFirstElement).chain(self.mOtherElements.iter_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Iterate over the array elements.
|
||||||
pub fn iter(&self) -> Chain<Once<&T>, Iter<T>> {
|
pub fn iter(&self) -> Chain<Once<&T>, Iter<T>> {
|
||||||
once(&self.mFirstElement).chain(self.mOtherElements.iter())
|
once(&self.mFirstElement).chain(self.mOtherElements.iter())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that often structs containing autoarrays will have
|
/// Returns the length of the array.
|
||||||
// additional member fields that contain the length, which must be kept
|
///
|
||||||
// in sync
|
/// Note that often structs containing autoarrays will have additional
|
||||||
|
/// member fields that contain the length, which must be kept in sync.
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
1 + self.mOtherElements.len()
|
1 + self.mOtherElements.len()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue