easytime 0.2.8

Providing wrapper types for safely performing panic-free checked arithmetic on instants and durations.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// SPDX-License-Identifier: Apache-2.0 OR MIT

use core::fmt;

/// The error type returned when a conversion from `easytime` types to `std::time` types fails.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct TryFromTimeError(pub(crate) ());

impl fmt::Display for TryFromTimeError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.write_str("invalid arithmetic attempted on instants or durations")
    }
}

#[cfg(feature = "std")]
impl std::error::Error for TryFromTimeError {}