intervalmap 0.1.1

An interval set/map library inspired by Boost.Icl
Documentation
use std::fmt::Debug;

use num_traits::int::PrimInt;

/// A trait for types that can be used as interval indices.
///
/// This trait is automatically implemented for any type that satisfies
/// `PrimInt + Debug`. This restricts IndexType to primitive integer types only
/// (i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize).
///
/// Floating-point types (f32, f64) are explicitly excluded because they are
/// inappropriate for interval indexing due to non-discrete values and rounding issues.
///
/// The default index type for `IntervalSet` and `IntervalMap` is `u32`.
pub trait IndexType: PrimInt + Debug {}

// Blanket implementation for all primitive integer types meeting the requirements
impl<T> IndexType for T where T: PrimInt + Debug {}

#[cfg(test)]
mod tests {
    use super::*;

    fn assert_index_type<T: IndexType>() {}

    #[test]
    fn test_primitive_types_are_index_types() {
        assert_index_type::<u8>();
        assert_index_type::<u16>();
        assert_index_type::<u32>();
        assert_index_type::<u64>();
        assert_index_type::<usize>();
        assert_index_type::<i8>();
        assert_index_type::<i16>();
        assert_index_type::<i32>();
        assert_index_type::<i64>();
        assert_index_type::<isize>();
    }
}