Skip to content

Commit b9a28b4

Browse files
committed
time: require a type when only milliseconds are supported
The from method is for milliseconds to Hz conversion, so make sure it only accepts a milliseconds type, given that it only handles 0..1000. Signed-off-by: Karl Palsson <karlp@etactica.com>
1 parent 6f457be commit b9a28b4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/time.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ impl Into<KiloHertz> for MegaHertz {
7777
}
7878
}
7979

80-
impl From<u32> for Hertz {
81-
fn from(ms: u32) -> Self {
82-
if ms <= 1000 {
83-
Hertz((1000 + ms / 2) / ms)
80+
impl From<MilliSeconds> for Hertz {
81+
fn from(ms: MilliSeconds) -> Self {
82+
if ms.0 <= 1000 {
83+
Hertz((1000 + ms.0 / 2) / ms.0)
8484
} else {
8585
Hertz(1)
8686
}

0 commit comments

Comments
 (0)