#no-std #iterators

no-std ix-rs

A trait for values that permit contiguous subranges

10 releases

0.7.4 Mar 12, 2023
0.7.3 Mar 12, 2023
0.6.3 Mar 11, 2023
0.5.0 Mar 11, 2023
0.1.0 Mar 10, 2023

#87 in No standard library

Download history 245/week @ 2023-03-09 10/week @ 2023-03-16 22/week @ 2023-03-23 18/week @ 2023-04-06 33/week @ 2023-04-13 6/week @ 2023-04-27 35/week @ 2023-05-04 7/week @ 2023-05-11 7/week @ 2023-05-18 16/week @ 2023-05-25

65 downloads per month

MIT license

8KB
59 lines

ix-rs

A trait for values that permit contiguous subranges.
This is a port of the Ix class from Haskell to a trait in Rust. However, its use should not be limited to the original design goal.

This crate provides the Ix trait:

pub trait Ix: PartialOrd + Sized {
    type Range: Iterator<Item = Self>;

    // Required methods
    fn range(min: Self, max: Self) -> Self::Range;
    fn index_checked(self, min: Self, max: Self) -> Option<usize>;
    fn in_range(self, min: Self, max: Self) -> bool;
    fn range_size_checked(min: Self, max: Self) -> Option<usize>;

    // Provided methods
    fn index(self, min: Self, max: Self) -> usize { ... }
    fn range_size(min: Self, max: Self) -> usize { ... }
}

See the documentation for more details.


lib.rs:

This crate provides a trait ([Ix]) for values that permit contiguous subranges.

No runtime deps