Fix reverse iteration in cretonne-entity's Iter.
A `DoubleEndedIterator` needs to track both a forward position and a reverse position, so that `next_back()` can pop from the back of the sequence.
This commit is contained in:
@@ -11,11 +11,11 @@ pub struct Keys<K: EntityRef> {
|
||||
}
|
||||
|
||||
impl<K: EntityRef> Keys<K> {
|
||||
/// Create a `Keys` iterator that visits `count` entities starting from 0.
|
||||
pub fn new(count: usize) -> Self {
|
||||
/// Create a `Keys` iterator that visits `len` entities starting from 0.
|
||||
pub fn with_len(len: usize) -> Self {
|
||||
Self {
|
||||
pos: 0,
|
||||
rev_pos: count,
|
||||
rev_pos: len,
|
||||
unused: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user