-
Notifications
You must be signed in to change notification settings - Fork 629
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
[API design] copy_from returns bool #901
Comments
Fixes image-rs#901 Returning a Result instead of a boolean should simplify error handling, and prevent accidentally ignoring errors.
I'd like to resole this one way or another for the next breaking release–
|
I don't think introducing a panic would be a good idea. It would just make the library less safe to use... |
Less safe? Not quite sure what you mean. If the copy operation is necessary to avoid leaking data of other clients through a buffer reuse then the Note: I'm not saying to change the method into something that panics, without offering any alternative. The trait should, imo, be a (minimal) set of accessor functions on which other abstractions can be built.
The current I also find an |
All of these functions are extremely simple, they basically just loop over each pixel in some rectangle and copy over the value at that location to another another image. This basically amounts to 3 lines of code. Convenience functions are nice, but there is no need to handle every possible case since users can easily just implement there own versions if necessary and if a user wants a non-panicking version of one of the current functions, they don't even need to do that: it is enough to just validate the preconditions before making the call. |
I thought I'd create a PR for direct comparison (#905, #963). The alternative would An third alternative: combine both. Keep the |
This was closed by error because of a wrong manipulation I made. Can someone reopen this issue ? |
Since no consensus seems to be reached here, maybe we should at least add a |
Sorry this has been dragging on so long! Could you fix the CI issue on #1004 and then I'll go ahead and merge it? |
Hello, and thank you for this very useful crate!
I stumbled upon
GenericImage::copy_from
, that returnsfalse
when the operation fails. This is not very idiomatic in rust, and makes error handling more difficult. It would be nice if the method could return aResult<()>
. This would prevent crate users from inadvertently ignoring an error.The text was updated successfully, but these errors were encountered: