@@ -46,28 +46,28 @@ impl TimeSpan {
46
46
}
47
47
48
48
#[ inline]
49
- pub fn total_millis ( & self ) -> f32 {
50
- self . total_seconds ( ) * 1000.
49
+ pub fn as_millis ( & self ) -> f32 {
50
+ self . as_seconds ( ) * 1000.
51
51
}
52
52
53
53
#[ inline]
54
- pub fn total_seconds ( & self ) -> f32 {
54
+ pub fn as_seconds ( & self ) -> f32 {
55
55
self . seconds
56
56
}
57
57
58
58
#[ inline]
59
- pub fn total_minutes ( & self ) -> f32 {
60
- self . total_seconds ( ) / 60.
59
+ pub fn as_minutes ( & self ) -> f32 {
60
+ self . as_seconds ( ) / 60.
61
61
}
62
62
63
63
#[ inline]
64
- pub fn total_hours ( & self ) -> f32 {
65
- self . total_minutes ( ) / 60.
64
+ pub fn as_hours ( & self ) -> f32 {
65
+ self . as_minutes ( ) / 60.
66
66
}
67
67
68
68
#[ inline]
69
- pub fn total_days ( & self ) -> f32 {
70
- self . total_hours ( ) / 24.
69
+ pub fn as_days ( & self ) -> f32 {
70
+ self . as_hours ( ) / 24.
71
71
}
72
72
}
73
73
@@ -145,11 +145,11 @@ impl From<TimeSpan> for Duration {
145
145
impl Display for TimeSpan {
146
146
fn fmt ( & self , formatter : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
147
147
match self {
148
- _ if self . total_days ( ) > 1. => write ! ( formatter, "{} days" , self . total_days ( ) ) ,
149
- _ if self . total_hours ( ) > 1. => write ! ( formatter, "{} hours" , self . total_hours ( ) ) ,
150
- _ if self . total_minutes ( ) > 1. => write ! ( formatter, "{} minutes" , self . total_minutes ( ) ) ,
151
- _ if self . total_seconds ( ) > 1. => write ! ( formatter, "{} seconds" , self . total_seconds ( ) ) ,
152
- _ => write ! ( formatter, "{} milliseconds" , self . total_millis ( ) ) ,
148
+ _ if self . as_days ( ) > 1. => write ! ( formatter, "{} days" , self . as_days ( ) ) ,
149
+ _ if self . as_hours ( ) > 1. => write ! ( formatter, "{} hours" , self . as_hours ( ) ) ,
150
+ _ if self . as_minutes ( ) > 1. => write ! ( formatter, "{} minutes" , self . as_minutes ( ) ) ,
151
+ _ if self . as_seconds ( ) > 1. => write ! ( formatter, "{} seconds" , self . as_seconds ( ) ) ,
152
+ _ => write ! ( formatter, "{} milliseconds" , self . as_millis ( ) ) ,
153
153
}
154
154
}
155
155
}
@@ -216,35 +216,35 @@ mod tests {
216
216
fn test_time_span_from_millis ( ) {
217
217
let time_span = TimeSpan :: from_millis ( 100.0 ) ;
218
218
219
- assert_eq ! ( time_span. total_millis ( ) , 100.0 ) ;
219
+ assert_eq ! ( time_span. as_millis ( ) , 100.0 ) ;
220
220
}
221
221
222
222
#[ test]
223
223
fn test_time_span_from_seconds ( ) {
224
224
let time_span = TimeSpan :: from_seconds ( 2.5 ) ;
225
225
226
- assert_eq ! ( time_span. total_millis ( ) , 2500.0 ) ;
226
+ assert_eq ! ( time_span. as_millis ( ) , 2500.0 ) ;
227
227
}
228
228
229
229
#[ test]
230
230
fn test_time_span_from_minutes ( ) {
231
231
let time_span = TimeSpan :: from_minutes ( 1.5 ) ;
232
232
233
- assert_eq ! ( time_span. total_millis ( ) , 90000.0 ) ;
233
+ assert_eq ! ( time_span. as_millis ( ) , 90000.0 ) ;
234
234
}
235
235
236
236
#[ test]
237
237
fn test_time_span_from_hours ( ) {
238
238
let time_span = TimeSpan :: from_hours ( 0.5 ) ;
239
239
240
- assert_eq ! ( time_span. total_millis ( ) , 1800000.0 ) ;
240
+ assert_eq ! ( time_span. as_millis ( ) , 1800000.0 ) ;
241
241
}
242
242
243
243
#[ test]
244
244
fn test_u8_into_time_span ( ) {
245
245
let value: u8 = 10 ;
246
246
let time_span = value. milliseconds ( ) ;
247
247
248
- assert_eq ! ( time_span. total_millis ( ) , 10.0 ) ;
248
+ assert_eq ! ( time_span. as_millis ( ) , 10.0 ) ;
249
249
}
250
250
}
0 commit comments