11 unstable releases (3 breaking)
0.8.0 | Aug 16, 2023 |
---|---|
0.7.4 | Mar 12, 2023 |
0.6.3 | Mar 11, 2023 |
0.5.0 | Mar 11, 2023 |
0.1.0 |
|
#293 in No standard library
28 downloads per month
9KB
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.
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.