ospf_rust_math/algebra/operator/algorithmic/
range_to.rs1use std::ops::Range;
2
3use crate::algebra::*;
4
5pub trait RangeTo: Sized {
6 fn until(self, rhs: Self) -> Range<Self>;
7}
8
9macro_rules! int_range_to_template {
10 ($($type:ident)*) => ($(
11 impl RangeTo for $type {
12 fn until(self, rhs: Self) -> Range<$type> {
13 self..rhs
14 }
15 }
16
17 impl RangeTo for &$type {
18 fn until(self, rhs: Self) -> Range<Self> {
19 self..rhs
20 }
21 }
22 )*)
23}
24int_range_to_template! { i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 }