Fallible functions should return Result instead of Option
notgull opened this issue · comments
The pattern in this crate seems to be that fallible functions (like Pixmap::new()
) return Option<T>
instead of Result<T, Error>
. I was wondering if it was a deliberate choice to use Option<T>
instead of having error types? It would be more idiomatic to return a ZST error type of some kind as a Result
instead of an Option
.
It would be more idiomatic to return a ZST error type of some kind as a Result instead of an Option.
I work with Rust for a long time and never seen such pattern. Option<T>
is Result<T, ()>
, if you think about it.
So the current code is correct and I have no plans on changing it.
PS: Paint methods that return Option<()>
will be replaced with just log warnings eventually.