rune/runtime/
steps_between.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub(crate) trait StepsBetween {
    fn steps_between(start: Self, end: Self) -> Option<usize>;
}

impl StepsBetween for i64 {
    #[inline]
    fn steps_between(start: Self, end: Self) -> Option<usize> {
        usize::try_from(end.checked_sub(start)?).ok()
    }
}

impl StepsBetween for u64 {
    #[inline]
    fn steps_between(start: Self, end: Self) -> Option<usize> {
        usize::try_from(end.checked_sub(start)?).ok()
    }
}