X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Ftime.rs;h=a6e6f4d1fda6b6e58a102a0baeb97cbed102159f;hb=a85d5b14444f3ef2dab994b404f4fb37635a3824;hp=0d969e7470952625d8db04965220c25df589f30f;hpb=63c77a960b3e35a3c28a874b8d321e38831543a0;p=rust-lightning diff --git a/lightning/src/util/time.rs b/lightning/src/util/time.rs index 0d969e74..a6e6f4d1 100644 --- a/lightning/src/util/time.rs +++ b/lightning/src/util/time.rs @@ -59,15 +59,15 @@ impl Sub for Eternity { } #[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[cfg(not(feature = "no-std"))] +#[cfg(feature = "std")] pub struct MonotonicTime(std::time::Instant); /// The amount of time to shift `Instant` forward to prevent overflow when subtracting a `Duration` /// from `Instant::now` on some operating systems (e.g., iOS representing `Instance` as `u64`). -#[cfg(not(feature = "no-std"))] +#[cfg(feature = "std")] const SHIFT: Duration = Duration::from_secs(10 * 365 * 24 * 60 * 60); // 10 years. -#[cfg(not(feature = "no-std"))] +#[cfg(feature = "std")] impl Time for MonotonicTime { fn now() -> Self { let instant = std::time::Instant::now().checked_add(SHIFT).expect("Overflow on MonotonicTime instantiation"); @@ -93,7 +93,7 @@ impl Time for MonotonicTime { } } -#[cfg(not(feature = "no-std"))] +#[cfg(feature = "std")] impl Sub for MonotonicTime { type Output = Self; @@ -177,7 +177,7 @@ pub mod tests { } #[test] - #[cfg(not(feature = "no-std"))] + #[cfg(feature = "std")] fn monotonic_time_subtracts() { let now = super::MonotonicTime::now(); assert!(now.elapsed() < Duration::from_secs(10));