Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ExactSizeIterator for accessor::util::Iter #271

Merged
merged 2 commits into from
Nov 21, 2019

Conversation

aloucks
Copy link
Contributor

@aloucks aloucks commented Nov 17, 2019

This trait was implemented for Iter prior to 0.14. It appears that
the missing trait implementation was an oversight when sparse
accessors were implemented in #246.

This trait was implemented for `Iter` prior to 0.14. It appears that
the missing trait implementation was an oversight when sparse
accessors were implemented in gltf-rs#246.
@alteous
Copy link
Member

alteous commented Nov 18, 2019

Thanks for the PR! It's not an oversight per se, I didn't think it made sense at the time. After re-reading the ExactSizeIterator docs I don't think this implementation is appropriate.

I think we would need to do something like this instead:

impl<'a, T: Item> ExactSizeIterator for SparseIter<'a, T> {}
impl<'a, T: Item> Iterator for SparseIter<'a, T> {
    ...
    fn size_hint(&self) -> usize {
        let hint = self.values.len() - self.counter;
        (hint, Some(hint))
    }
}

Added size_hint to SparseIter based on feedback and added all
ItemIter Iterator overloads to Iter as well.
@aloucks aloucks force-pushed the exact_size_iterator branch from 96045ca to e5e674c Compare November 20, 2019 02:26
@aloucks
Copy link
Contributor Author

aloucks commented Nov 20, 2019

@alteous I've updated this based on your feedback and also added the other methods to Iter that were implemented for ItemIter.

@alteous
Copy link
Member

alteous commented Nov 21, 2019

LGTM, thanks. 👍

@alteous alteous merged commit f489c26 into gltf-rs:master Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants