earliest

Function earliest 

Source
pub fn earliest(times: &[SystemTime]) -> Option<SystemTime>
Expand description

Find the earliest time in a collection. If the collection is empty, returns None.

§Arguments

  • times - A slice of SystemTime items.

§Returns

  • Option<SystemTime> - The earliest SystemTime, or None if the collection is empty.

§Examples

use std::time::{SystemTime, Duration};
use lowdash::earliest;

let t1 = SystemTime::UNIX_EPOCH;
let t2 = t1 + Duration::new(60, 0);
let t3 = t1 + Duration::new(120, 0);
let times = vec![t2, t1, t3];
let earliest_time = earliest(&times);
assert_eq!(earliest_time, Some(t1));