odsek 0.1.0

Lazy, pull-based composition of mathematical interval sets with open/closed endpoints, no_std-compatible.
Documentation
//! # Lazy interval-set composition
//!
//! `odsek` provides allocation-free, pull-based composition of ordered,
//! non-overlapping mathematical interval sets. Each [`Interval`] carries a
//! value, so intersections and unions can also be read as joins over tagged
//! segments.
//!
//! The core API is `no_std` and does not allocate. Streams are queried through
//! [`Intervals::head`], which returns the next interval after a requested
//! position; iteration and combinators are layered on top of that primitive.
//!
//! ## Endpoint flavors
//!
//! * [`EndpointOC`] supports explicitly open or closed boundaries.
//! * [`EndpointSymmetric`] represents the common `[a, b)` convention: closed
//!   on the left, open on the right.
//!
//! ## Composition
//!
//! With the default `operators` feature, `&` computes intersection and `|`
//! computes union. Disable default features to use the explicit [`and`] and
//! [`or`] functions instead.
//!
//! ## Examples
//!
//! ```
//! use odsek::*;
//!
//! let ia = Interval::new(EndpointOC::Closed(1), EndpointOC::Closed(3), "A");
//! let ib = Interval::new(EndpointOC::Open(2), EndpointOC::Open(4), "B");
//!
//! let isa = IntervalsSingle::new(ia);
//! let isb = IntervalsSingle::new(ib);
//!
//! let and_ab = and(isa, isb);
//! let and_ab_vec = and_ab.into_iter().collect::<Vec<_>>();
//!
//! assert_eq!(and_ab_vec.len(), 1);
//! assert_eq!(and_ab_vec[0], Interval::new(EndpointOC::Open(2), EndpointOC::Closed(3), ("A","B")));
//! ```

// no_std when not testing
#![cfg_attr(not(test), no_std)]

mod interval;
pub use self::interval::*;

mod endpointoc;
mod endpointsymmetric;

mod endpoint;
pub use self::endpoint::*;

pub(crate) mod ivs;
pub use self::ivs::*;

mod iterator;
pub use self::iterator::*;