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 the ability to consume the IconImage #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

StratusFearMe21
Copy link

This is useful for embedding an ico window icon and using it with winit, which requires that the icon is a Vec<u8>

Copy link
Owner

@mdsteele mdsteele left a comment

Choose a reason for hiding this comment

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

Thanks, this looks like a good method to add.

src/image.rs Outdated

/// Consumes this `IconImage` and returns the raw RGBA data in row-major order
/// as an owned `Vec<u8>`
pub fn take_rgba_data(self) -> Vec<u8> {
Copy link
Owner

Choose a reason for hiding this comment

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

Looking at standard library methods, it seems like the usual Rust convention is for "take" to refer to &mut self methods that extract an owned value, leaving (that part of) the receiver object empty (e.g. slice::take_last), while self methods that consume the receiver entirely to return an owned value have names starting with "into" (e.g. Box::into_raw). So by that convention, this method should probably be called into_rgba_data instead.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, you're right. Updated

@mdsteele
Copy link
Owner

Looks good, thanks, just need to fix the lint error I think? (Looks like just need to run cargo fmt.)

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.

None yet

2 participants