captcha
captcha copied to clipboard
Unhelpful panic inside of view() when add_char was never called
Hi!
I'm starting to use this library in my project and I've already run into one of your TODOs, specifically in lib.rs line 250, there's a panic when you haven't called add_char yet (the TODO is already there at line 256).
A simple solution would be calling .saturating_sub(w / 2)
instead of using -
, but I think ideally, the whole Captcha type should be refactored into two different ones (like a typestate, you'd then have a CaptchaConfig
type and you can only get a Captcha
from it if you set all the required values, and that captcha can then be cropped, rendered etc).
I've also noticed that there are a lot of minor parts of the code that aren't very idiomatic (there are 31 clippy warnings); for example, some functions have three nested matches that could easily be replaced with either ?
or an .and_then
chain, some struct initializers have redundant field names, and there are lots of clones on Copy types.
Would you be interested in a bigger PR fixing all of the smaller issues? I'd love to contribute to this project. Best regards
are you working on a pr for it?