//! Utilities for the `NSEnumerator` class. use objc2::rc::Retained; use objc2::Message;
usecrate::{iter, NSEnumerator};
// TODO: Measure whether iterating through `nextObject` or fast enumeration is // fastest. // impl<ObjectType: Message> Iterator for NSEnumerator<ObjectType> { // type Item = Retained<ObjectType>; // // #[inline] // fn next(&mut self) -> Option<Retained<ObjectType>> { // self.nextObject() // } // }
impl<ObjectType: Message> NSEnumerator<ObjectType> { /// Iterate over the enumerator's elements. #[inline] pubfn iter(&self) -> Iter<'_, ObjectType> {
Iter(iter::Iter::new(self))
}
/// Iterate over the enumerator without retaining the elements. /// /// Consider using the [`iter`](Self::iter) method instead, unless you're /// seeing performance issues from the retaining. /// /// # Safety /// /// The enumerator and the underlying collection must not be mutated while /// the iterator is alive. #[inline] pubunsafefn iter_unchecked(&self) -> IterUnchecked<'_, ObjectType> {
IterUnchecked(iter::IterUnchecked::new(self))
}
}
unsafeimpl<ObjectType: Message> iter::FastEnumerationHelper for NSEnumerator<ObjectType> { type Item = ObjectType;
/// An iterator over unretained items in an enumerator. /// /// # Safety /// /// The enumerator and the underlying collection must not be mutated while /// this is alive. #[derive(Debug)] pubstruct IterUnchecked<'a, ObjectType: Message + 'a>(
iter::IterUnchecked<'a, NSEnumerator<ObjectType>>,
);
/// A consuming iterator over the items in an enumerator. #[derive(Debug)] pubstruct IntoIter<ObjectType: Message>(iter::IntoIter<NSEnumerator<ObjectType>>);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.