We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 16f2870 commit 614bfcaCopy full SHA for 614bfca
Rust/rustifinity/challenges/the-from-trait.rs
@@ -0,0 +1,31 @@
1
+pub struct Minutes(pub i32);
2
+pub struct Hours(pub i32);
3
+pub struct Days(pub i32);
4
+
5
+impl From<Minutes> for Hours {
6
+ fn from(minutes: Minutes) -> Hours {
7
+ // Implement the minute to hour conversion here
8
+ Hours(minutes.0 / 60)
9
+ }
10
+}
11
12
+// TODO: implement from hours to days
13
+impl From<Hours> for Days {
14
+ fn from(hours: Hours) -> Days {
15
+ Days(hours.0 / 24)
16
17
18
19
+// TODO: implement from minutes to days
20
+impl From<Minutes> for Days {
21
+ fn from(minutes: Minutes) -> Days {
22
+ Days(minutes.0 / (24 * 60))
23
24
25
26
+// TODO: implement from days to hours
27
+impl From<Days> for Hours {
28
+ fn from(days: Days) -> Hours {
29
+ Hours(days.0 * 24)
30
31
0 commit comments