a sign enum. pass it to operations to run forwards or backwards.
use sign::{Sign, Directional};
// pick a direction and run the same code either way
let dir = if forward { Sign::Positive } else { Sign::Negative };
dir.add_assign(&mut i, 1); // i += 1 or i -= 1
dir.max(a, b); // max(a, b) or min(a, b)
let (lo, hi) = dir.order(a, b); // (a, b) or (b, a)// walk an iterator forward or backward
for ch in "hello".chars().direction(dir) {
// ...
}// index a slice in either direction
let s = "hello";
let sub = &s[dir.range(1..4)];