Implement IntoIterator for IndexVec

This fixes a clippy warning and slightly improves ergonomic.

This is technically a breaking change, but it is unlikely to break code
in practice, since `IntoIterator` is in Rust's prelude.
This commit is contained in:
Vinzent Steinberg
2020-07-31 17:41:37 +02:00
parent 28bf11d237
commit 19fc4e8008
+6 -1
View File
@@ -85,10 +85,15 @@ impl IndexVec {
IndexVec::USize(ref v) => IndexVecIter::USize(v.iter()),
}
}
}
impl IntoIterator for IndexVec {
type Item = usize;
type IntoIter = IndexVecIntoIter;
/// Convert into an iterator over the indices as a sequence of `usize` values
#[inline]
pub fn into_iter(self) -> IndexVecIntoIter {
fn into_iter(self) -> IndexVecIntoIter {
match self {
IndexVec::U32(v) => IndexVecIntoIter::U32(v.into_iter()),
IndexVec::USize(v) => IndexVecIntoIter::USize(v.into_iter()),