//! Utilities for the `NSEnumerator` class. use objc2::rc::Retained; use objc2::Message; use super::iter; use crate::Foundation::NSEnumerator; // TODO: Measure whether iterating through `nextObject` or fast enumeration is // fastest. // impl Iterator for NSEnumerator { // type Item = Retained; // // #[inline] // fn next(&mut self) -> Option> { // self.nextObject() // } // } unsafe impl iter::FastEnumerationHelper for NSEnumerator { type Item = T; #[inline] fn maybe_len(&self) -> Option { None } } /// A consuming iterator over the items of a `NSEnumerator`. #[derive(Debug)] pub struct IntoIter(iter::IntoIter>); __impl_iter! { impl<'a, T: Message> Iterator> for IntoIter { ... } } impl objc2::rc::RetainedIntoIterator for NSEnumerator { type Item = Retained; type IntoIter = IntoIter; #[inline] fn id_into_iter(this: Retained) -> Self::IntoIter { IntoIter(super::iter::IntoIter::new(this)) } } // TODO: Does fast enumeration modify the enumeration while iterating?