1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::ops::{Range, RangeFrom, RangeTo, RangeFull};

/// Temporary type until the one in stdlib it made stable
pub enum RangeArgument {
    RangeFrom(usize),
    Range(usize, usize),
    RangeTo(usize),
}

impl From<Range<usize>> for RangeArgument {
    fn from(r: Range<usize>) -> RangeArgument {
        RangeArgument::Range(r.start, r.end)
    }
}
impl From<RangeFrom<usize>> for RangeArgument {
    fn from(r: RangeFrom<usize>) -> RangeArgument {
        RangeArgument::RangeFrom(r.start)
    }
}
impl From<RangeTo<usize>> for RangeArgument {
    fn from(r: RangeTo<usize>) -> RangeArgument {
        RangeArgument::RangeTo(r.end)
    }
}
impl From<RangeFull> for RangeArgument {
    fn from(_: RangeFull) -> RangeArgument {
        RangeArgument::RangeFrom(0)
    }
}