Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRefactored EventLoop::timeout_ms to use Duration instead of u64 #48
Conversation
zslayton
changed the title
Refactored EventLoop::timeout_ms to use Duration instead of uint.
Refactored EventLoop::timeout_ms to use Duration instead of u64
Nov 12, 2014
This comment has been minimized.
This comment has been minimized.
sschepens
commented
Nov 12, 2014
|
I was thinking of dropping a pull request for this too, we have to be careful when casting i64 to u64, if it's negative it will give a huve positive u64, maybe we can error o reject negative i64s? or maybe set timeout to 0 when it's negative |
This comment has been minimized.
This comment has been minimized.
|
I considered this -- in honesty, I'm not sure why Duration uses signed values. I'm not sure what it would mean to have a negative duration of time. "Two days ago" is still a duration of two days. Perhaps I should open a ticket upstream to discuss it. In the meantime, @carllerche, how would you prefer that this case be handled? |
This comment has been minimized.
This comment has been minimized.
sschepens
commented
Nov 12, 2014
|
Yeah, i also thought about it, it's kind of misleading to have negative durations but, but golang seems to have them too and there are some use cases where it's actually handy to have negative durations. |
This comment has been minimized.
This comment has been minimized.
|
For now, if the duration is negative, I would set a 0ms timeout. I would also open an issue upstream. I am going to discuss this issue with @aturon. Besides that, the PR looks good. Thanks |
This comment has been minimized.
This comment has been minimized.
|
I've started a thread on discuss.rust-lang.org. I'll tweak the PR to set a 0ms timeout this evening. |
zslayton
force-pushed the
zslayton:master
branch
from
8f089ee
to
3078383
Nov 13, 2014
carllerche
merged commit 3078383
into
carllerche:master
Nov 13, 2014
1 check passed
This comment has been minimized.
This comment has been minimized.
|
THanks for the PR :) |
zslayton commentedNov 12, 2014
Addresses #32. Removed
_msfrom the method name since the Duration class can represent a range of units.