Skip to content

Commit

Permalink
Implement IntoIterator for IndexVec
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vks committed Jul 31, 2020
1 parent 28bf11d commit 19fc4e8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/seq/index.rs
Expand Up @@ -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()),
Expand Down

0 comments on commit 19fc4e8

Please sign in to comment.