This commit is contained in:
2025-01-29 10:30:49 -05:00
parent 7aebdc3c78
commit db42964a47
2 changed files with 28 additions and 17 deletions

View File

@@ -6,6 +6,7 @@ where
RangeInclusive<T>: Iterator<Item = T> + DoubleEndedIterator,
Rev<RangeInclusive<T>>: Iterator<Item = T>,
{
// check that x is in range
if min > x || x > max {
return Vec::new();
}
@@ -35,6 +36,9 @@ mod test {
assert_eq!(split_from(0, 6, 6), vec![vec![5, 4, 3, 2, 1, 0]]);
// test out-of-bounds and also generics
assert_eq!(split_from::<i16>(-1, 4, 10), Vec::<Vec<i16>>::new());
assert_eq!(
split_from::<i16>(-1i16, 4i16, 10i16),
Vec::<Vec<i16>>::new()
);
}
}