summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hurst <tom@hur.st>2018-09-04 22:50:39 +0100
committerKartikaya Gupta (kats) <staktrace@users.noreply.github.com>2018-09-05 04:05:28 -0400
commit96808caf7d15cb73da84dc1bf8796fbe7136693e (patch)
treec5a0ea7a68229365279e23fcb18bf016681f3469
parent44e2c74bc6c3427af94f46e91e1d73bbf8a3346e (diff)
downloadmailparse-96808caf7d15cb73da84dc1bf8796fbe7136693e.tar.gz
mailparse-96808caf7d15cb73da84dc1bf8796fbe7136693e.tar.xz
Use i64::from(x) over x as i64
clippy:cast_lossless
-rw-r--r--src/dateparse.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/dateparse.rs b/src/dateparse.rs
index 4da8b13..68c2ae3 100644
--- a/src/dateparse.rs
+++ b/src/dateparse.rs
@@ -117,7 +117,7 @@ pub fn dateparse(date: &str) -> Result<i64, &'static str> {
Ok(v) => v,
Err(_) => return Err("Invalid year"),
};
- result = seconds_to_date(year as i64, month as i64, day_of_month as i64);
+ result = seconds_to_date(i64::from(year), i64::from(month), i64::from(day_of_month));
state = DateParseState::Hour;
continue;
}
@@ -126,7 +126,7 @@ pub fn dateparse(date: &str) -> Result<i64, &'static str> {
Ok(v) => v,
Err(_) => return Err("Invalid hour"),
};
- result += 3600 * (hour as i64);
+ result += 3600 * i64::from(hour);
state = DateParseState::Minute;
continue;
}
@@ -135,7 +135,7 @@ pub fn dateparse(date: &str) -> Result<i64, &'static str> {
Ok(v) => v,
Err(_) => return Err("Invalid minute"),
};
- result += 60 * (minute as i64);
+ result += 60 * i64::from(minute);
state = DateParseState::Second;
continue;
}
@@ -144,7 +144,7 @@ pub fn dateparse(date: &str) -> Result<i64, &'static str> {
Ok(v) => v,
Err(_) => return Err("Invalid second"),
};
- result += second as i64;
+ result += i64::from(second);
state = DateParseState::Timezone;
continue;
}
@@ -173,9 +173,9 @@ pub fn dateparse(date: &str) -> Result<i64, &'static str> {
let tz_mins = tz % 100;
let tz_delta = (tz_hours * 3600) + (tz_mins * 60);
if tz_sign < 0 {
- result += tz_delta as i64;
+ result += i64::from(tz_delta);
} else {
- result -= tz_delta as i64;
+ result -= i64::from(tz_delta);
}
break;
}