[−][src]Function babalcore::unwrap_now
pub fn unwrap_now(now: Option<Instant>) -> Instant
Return the time contained in the option if it is defined. If not (None was passed) returns the result of an actual call to Instant::now(). This is useful for testing: in mainstream production code, just pass None, but for testing it is possible to pass fake instants.
use std::time::Instant; use babalcore::*; // Use default. let t1 = unwrap_now(None); // Override with custom instant. let t2 = unwrap_now(Some(Instant::now())); assert!(t1 <= t2);