Open kangalio opened 4 years ago
Good idea. I don't know what @houqp's opinion on changing the API is. Leptess hasn't had its 1.0.0 release, so API changes should be ok.
I suppose another alternative would be to return something like this
Result<(), Leptess::Error>
Where Error
is an enum with a PixReadError variant
:+1: on this breaking change, If there is extra error context we can pass back to caller, we should use Result, otherwise, Option would be better.
In LepTess::set_image,
bool
is used as a return value to indicate success or failure. Booleans are not a good choice for a return value for this use case. Better isOption<()>
orResult<(), ()>
(I personally thinkOption<()>
is nicer, butResult<(), ()>
objectively makes more sense)As a side-effect of this, the code inside the functions can become much more concise and idiomatic:
https://github.com/kangalioo/leptess/commit/786a7519f904e7a6eafa9be18f8a5f201bff9120