polylane 0.10.0

Portable and versatile SIMD.
Documentation
// Copyright 2025 Gabriel Bjørnager Jensen.
//
// This Source Code Form is subject to the terms of
// the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, you
// can obtain one at:
// <https://mozilla.org/MPL/2.0/>.

use crate::simd::SimdScalar;

use core::array;
use core::iter::FusedIterator;

/// An owning iterator of a SIMD vector.
#[derive(Clone, Debug)]
pub struct IntoIter<T: SimdScalar, const N: usize> {
	iter: array::IntoIter<T, N>,
}

impl<T: SimdScalar, const N: usize> IntoIter<T, N> {
	/// Constructs a new, owning iterator of a SIMD vector.
	#[inline]
	#[must_use]
	pub(crate) fn new(data: [T; N]) -> Self {
		Self { iter: data.into_iter() }
	}
}

impl<T: SimdScalar, const N: usize> DoubleEndedIterator for IntoIter<T, N> {
	#[inline]
	fn next_back(&mut self) -> Option<Self::Item> {
		self.iter.next_back()
	}
}

impl<T: SimdScalar, const N: usize> ExactSizeIterator for IntoIter<T, N> {}

impl<T: SimdScalar, const N: usize> FusedIterator for IntoIter<T, N> {}

impl<T: SimdScalar, const N: usize> Iterator for IntoIter<T, N> {
	type Item = T;

	#[inline]
	fn next(&mut self) -> Option<Self::Item> {
		self.iter.next()
	}

	#[inline]
	fn size_hint(&self) -> (usize, Option<usize>) {
		self.iter.size_hint()
	}
}