Function enum_iterator::previous

source ·
pub fn previous<T: Sequence>(x: &T) -> Option<T>
Expand description

Returns the previous value of type T or None if this was the beginning.

Same as Sequence::previous.

Example

use enum_iterator::{previous, Sequence};

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

assert_eq!(previous(&Day::Saturday), Some(Day::Friday));