use std::ops::{ RangeFull, RangeFrom, RangeTo, Range, }; // Taken from https://github.com/bluss/odds/blob/master/src/range.rs. /// **IndexRange** is implemented by Rust's built-in range types, produced /// by range syntax like `..`, `a..`, `..b` or `c..d`. pub trait IndexRange { #[inline] /// Start index (inclusive) fn start(&self) -> Option { None } #[inline] /// End index (exclusive) fn end(&self) -> Option { None } } impl IndexRange for RangeFull {} impl IndexRange for RangeFrom { #[inline] fn start(&self) -> Option { Some(self.start) } } impl IndexRange for RangeTo { #[inline] fn end(&self) -> Option { Some(self.end) } } impl IndexRange for Range { #[inline] fn start(&self) -> Option { Some(self.start) } #[inline] fn end(&self) -> Option { Some(self.end) } }