image: Allow any kind of data that implements AsRef<[u8]> for the i…#1551
Merged
hecrj merged 2 commits intoiced-rs:masterfrom Feb 17, 2023
Merged
image: Allow any kind of data that implements AsRef<[u8]> for the i…#1551hecrj merged 2 commits intoiced-rs:masterfrom
AsRef<[u8]> for the i…#1551hecrj merged 2 commits intoiced-rs:masterfrom
Conversation
Contributor
|
Image handle already uses an arc Line 11 in 370fa14 https://github.com/iced-rs/iced/blob/master/examples/pokedex/src/main.rs#L113 |
Contributor
Author
|
Ah I see, thanks! Then this can also become a plain Is the |
2ebb688 to
0ae1342
Compare
sdroege
commented
Nov 21, 2022
0ae1342 to
2009e68
Compare
sdroege
commented
Nov 21, 2022
…mage data It's not required anywhere for it to be a plain slice or a `Vec` and this makes it possible to use data allocated in a different way without copying.
2009e68 to
d7c8308
Compare
hecrj
approved these changes
Feb 17, 2023
Member
hecrj
left a comment
There was a problem hiding this comment.
Thanks for this!
I have moved the Arc from Handle to Bytes since the other fields in Data should be fairly cheap to Clone and we can get rid of the awkward trait this way.
sdroege
commented
Feb 18, 2023
| ImageBytes(self.0.clone_boxed()) | ||
| impl Bytes { | ||
| /// Creates new [`Bytes`] around `data`. | ||
| pub fn new(data: impl AsRef<[u8]> + Clone + Send + Sync + 'static) -> Self { |
Contributor
Author
There was a problem hiding this comment.
You don't really need the Clone here anymore as the Arc already gives you that :)
Do you want me to submit a PR for removing the trait bound or will you take care of the change?
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…mage data
It's not required anywhere for it to be a plain slice or a
Vecand this makes it possible to use data allocated in a different way without copying.Also store the data in an
Arcto allow cheap cloning.