feat: Accept durations as timeout arguments#172
Conversation
| impl From<Duration> for Timeout { | ||
| fn from(duration: Duration) -> Timeout { | ||
| if duration.is_zero() { | ||
| Timeout::Never |
There was a problem hiding this comment.
I don't think it's a good idea to convert Duration 0 to Never just because the 0 value means never.
If you handover a parameter of type Duration then this behavior would be very unexpected.
What if we convert a timeout of Duration of 0ms into a None timeout.
There was a problem hiding this comment.
But we have to return a Timeout object, we can't return Option<Timeout> (or at least I don't see how). Then either we take the user at their word and return Milliseconds(0) or we try to be smarter then them and return Default. What do you think ?
There was a problem hiding this comment.
I guess it's just weird API. then let's leave it like this. Thanks for the change, I'll just add a bit more documentation to make sure this is explained to the user.
See this discussion.