Skip to content

Commit 06b69af

Browse files
committed
Hertz: Replace Into impls with From impls
From the Rust docs: > One should always prefer implementing From over Into because > implementing From automatically provides one with an implementation of > Into thanks to the blanket implementation in the standard library.
1 parent 854526e commit 06b69af

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/time.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,21 @@ impl U32Ext for u32 {
141141
}
142142
}
143143

144-
impl Into<Hertz> for KiloHertz {
145-
fn into(self) -> Hertz {
146-
Hertz(self.0 * 1_000)
144+
impl From<KiloHertz> for Hertz {
145+
fn from(val: KiloHertz) -> Self {
146+
Self(val.0 * 1_000)
147147
}
148148
}
149149

150-
impl Into<Hertz> for MegaHertz {
151-
fn into(self) -> Hertz {
152-
Hertz(self.0 * 1_000_000)
150+
impl From<MegaHertz> for Hertz {
151+
fn from(val: MegaHertz) -> Self {
152+
Self(val.0 * 1_000_000)
153153
}
154154
}
155155

156-
impl Into<KiloHertz> for MegaHertz {
157-
fn into(self) -> KiloHertz {
158-
KiloHertz(self.0 * 1_000)
156+
impl From<MegaHertz> for KiloHertz {
157+
fn from(val: MegaHertz) -> Self {
158+
Self(val.0 * 1_000)
159159
}
160160
}
161161

0 commit comments

Comments
 (0)