diff --git a/crates/roc_std/src/roc_list.rs b/crates/roc_std/src/roc_list.rs index 5738d64fe5..fc4247f459 100644 --- a/crates/roc_std/src/roc_list.rs +++ b/crates/roc_std/src/roc_list.rs @@ -501,62 +501,6 @@ impl From<[T; SIZE]> for RocList { } } -impl<'a, T> IntoIterator for &'a RocList { - type Item = &'a T; - type IntoIter = core::slice::Iter<'a, T>; - - fn into_iter(self) -> Self::IntoIter { - self.as_slice().iter() - } -} - -impl IntoIterator for RocList { - type Item = T; - type IntoIter = IntoIter; - - fn into_iter(self) -> Self::IntoIter { - IntoIter { list: self, idx: 0 } - } -} - -pub struct IntoIter { - list: RocList, - idx: usize, -} - -impl Iterator for IntoIter { - type Item = T; - - fn next(&mut self) -> Option { - if self.list.len() <= self.idx { - return None; - } - - let elements = self.list.elements?; - let element_ptr = unsafe { elements.as_ptr().add(self.idx) }; - self.idx += 1; - - // Return the element. - Some(unsafe { ManuallyDrop::into_inner(element_ptr.read()) }) - } -} - -impl Drop for IntoIter { - fn drop(&mut self) { - // If there are any elements left that need to be dropped, drop them. - if let Some(elements) = self.list.elements { - // Set the list's length to zero to prevent double-frees. - // Note that this leaks if dropping any of the elements panics. - let len = mem::take(&mut self.list.length); - - // Drop the elements that haven't been returned from the iterator. - for i in self.idx..len { - mem::drop::(unsafe { ManuallyDrop::take(&mut *elements.as_ptr().add(i)) }) - } - } - } -} - impl Hash for RocList { fn hash(&self, state: &mut H) { // This is the same as Rust's Vec implementation, which