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

Add sparse accessor iterators #246

Merged
merged 1 commit into from
Sep 21, 2019
Merged

Conversation

alteous
Copy link
Member

@alteous alteous commented Aug 19, 2019

Fixes #154

fn buffer_view_slice<'a, 's, F>(view: buffer::View<'a>, get_buffer_data: F) -> &'s [u8]
where F: Fn(buffer::Buffer<'a>) -> Option<&'s [u8]>,
{
let big_slice = get_buffer_data(view.buffer()).unwrap(); // TODO: don't unwrap()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: don't unwrap()

Fix me


/// General iterator for an accessor.
#[derive(Clone, Debug)]
pub enum Iter<'a, T: Item> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider making Accessor an enum too

where F: Clone + Fn(buffer::Buffer<'a>) -> Option<&'s [u8]>,
{
let is_sparse = accessor.sparse().is_some();
Some(if is_sparse {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some(

Fix me: return None if get_buffer_data fails.

@alteous alteous merged commit 4b6b25e into gltf-rs:master Sep 21, 2019
aloucks added a commit to aloucks/gltf that referenced this pull request 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 gltf-rs#246.
@alteous alteous deleted the sparse-accessor branch April 28, 2023 11:15
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.

Sparse accessors are not handled correctly by iterators
1 participant