bunsen 0.37.0

bunsen is a batteries included common library for burn
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! # Range utilities

use std::ops::Range;

/// Converts a `usize` range to an `i32` range.
///
/// The bounds are cast with `as`, so a bound past `i32::MAX` wraps.
pub fn range_into(r: &Range<usize>) -> Range<i32> {
    r.start as i32..r.end as i32
}

/// Shifts both bounds of a range by `shift`.
pub fn shift_range(
    r: Range<i32>,
    shift: i32,
) -> Range<i32> {
    (r.start + shift)..(r.end + shift)
}