mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
implement into iterator
This commit is contained in:
parent
fa49f0368d
commit
dd24786e67
1 changed files with 19 additions and 0 deletions
|
@ -311,6 +311,25 @@ impl<'a, T> IntoIterator for &'a RocList<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> IntoIterator for RocList<T> {
|
||||
type Item = T;
|
||||
|
||||
type IntoIter = IntoIter<T>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
let remaining = self.len();
|
||||
|
||||
let buf = unsafe { NonNull::new_unchecked(self.elements as _) };
|
||||
let ptr = self.elements;
|
||||
|
||||
IntoIter {
|
||||
buf,
|
||||
ptr,
|
||||
remaining,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use core::ptr::NonNull;
|
||||
|
||||
pub struct IntoIter<T> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue