Function shift_range

Source
pub fn shift_range<T>(range: Range<T>, shift: Shift<T>) -> Option<Range<T>>
where T: PrimInt,
Expand description

Creates a new range with the start and end values shifted by the given amount.

ยงExample:

use query_range::{shift_range, Shift};

let test_str = "this is a test";

let range = 0..5;
assert_eq!(shift_range(range, Shift::Up(2)), Some(2..7));

let range = 0..5;
assert_eq!(shift_range(range, Shift::Up(20)), Some(20..25));