pipecircuit 0.0.4

Correct. Robust. Fast. Portable.
Documentation
use core::ops::{Bound, RangeBounds};

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct RangeIndexBounds<Key> {
    start: Bound<Key>,
    end: Bound<Key>,
}

impl<Key: Copy> RangeIndexBounds<Key> {
    pub fn from_range(range: impl RangeBounds<Key>) -> Self {
        Self {
            start: copied_bound(range.start_bound()),
            end: copied_bound(range.end_bound()),
        }
    }

    pub fn start(&self) -> Bound<&Key> {
        self.start.as_ref()
    }

    pub fn end(&self) -> Bound<&Key> {
        self.end.as_ref()
    }
}

fn copied_bound<Key: Copy>(bound: Bound<&Key>) -> Bound<Key> {
    match bound {
        Bound::Included(value) => Bound::Included(*value),
        Bound::Excluded(value) => Bound::Excluded(*value),
        Bound::Unbounded => Bound::Unbounded,
    }
}