mogwai
mogwai copied to clipboard
Use `NonZeroUsize` rather than `usize` to prevent panic scenario
A NonZeroUsize parameter instead of a usizeto specify the capacity of a bounded channel would eliminate the panic scenario.
Hey! Great idea.
It might take me a bit to get to this, I'm currently on holiday. If you're feeling antsy I would definitely accept a pull request.
I tried this out and although it is more correct to use a NonZeroUsize for the capacity, it is quite inconvenient. I also found that I just ended up calling 1.try_into().unwrap() while creating all of my channels and while this is more explicit (which I like) it was a pain. I temporarily included a constant const ONE: NonZeroUsize = ... but ultimately decided not to include this change in 0.6.
I might pick it back up for 0.7, but I might also just remove the channels in favor of Input, FanInput and Output.