pub fn previous_cycle<T: Sequence>(x: &T) -> Option<T>
Expand description

Returns the previous value of type T or last() if this was the beginning.

Example

use enum_iterator::{previous_cycle, Sequence};

#[derive(Debug, PartialEq, Sequence)]
enum Day { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }

assert_eq!(previous_cycle(&Day::Monday), Some(Day::Sunday));