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

Should the pixels implement Index<usize> and IndexMut<usize> #132

Closed
ripytide opened this issue Aug 14, 2024 · 1 comment
Closed

Should the pixels implement Index<usize> and IndexMut<usize> #132

ripytide opened this issue Aug 14, 2024 · 1 comment

Comments

@ripytide
Copy link
Contributor

My main inspiration is image-rs/image#2259, where the current image pixel types use an internal array like: struct Rgb<T>([T;3]) and also implement Index<usize> and IndexMutso if thergb` crates types also implemented those traits then the migration process would be easier.

On the other hand, using the field access (.r, .g, .b) seems much more readable to me so perhaps we shouldn't implement Index<usize> and instead refactor the image crate to field access when doing the migration.

@kornelski
Copy link
Owner

No, I think it'd be counter-productive. It would be confusing when working with slices of pixels.

Supporting something like pixel['r'] could be interesting, but that's pretty quirky and niche.

@kornelski kornelski closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2024
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

No branches or pull requests

2 participants