Refactor try_from and try_into error handing.

This commit is contained in:
Marcin Mielniczuk
2019-09-07 19:39:10 +02:00
committed by Jakub Konka
parent 14aaffd46f
commit b09f7e860f
5 changed files with 24 additions and 26 deletions

View File

@@ -6,5 +6,5 @@ pub(crate) fn systemtime_to_timestamp(st: SystemTime) -> Result<u64> {
.map_err(|_| Error::EINVAL)? // date earlier than UNIX_EPOCH
.as_nanos()
.try_into()
.map_err(|_| Error::EOVERFLOW) // u128 doesn't fit into u64
.map_err(Into::into) // u128 doesn't fit into u64
}