Skip to main content

Crate use_interval

Crate use_interval 

Source
Expand description

§use-interval

Small interval and bound primitives for RustUse.
Explicit open, closed, half-open, and unbounded intervals with containment, overlap, and intersection operations.

Rust 1.95.0+ Edition 2024 Interval primitives License MIT or Apache-2.0

§Install

[dependencies]
use-interval = "0.0.4"

§What belongs here

use-interval owns reusable interval and bound primitives. It provides open, closed, half-open, and unbounded intervals together with small operations such as containment, overlap, emptiness checks, and intersection.

The crate stays intentionally narrow and dependency-free so adjacent crates can reuse interval semantics without pulling in domain-specific policy.

§Neighboring crates

CrateResponsibility
use-intervalGeneric interval and bound primitives
use-realReal-number abstractions, validated finite values, and comparisons
use-calculusNumerical methods that may consume intervals
use-probabilityProbability-specific interval interpretations
use-statisticsStatistical confidence intervals and descriptive interpretation
use-geometryGeometry-specific bounds, boxes, and spatial interval compositions
use-optimizationOptimization algorithms and interval-based search strategies

use-interval intentionally does not define confidence interval types, geometry-specific bounding boxes, unit-aware intervals, or equation-solving algorithms.

§Examples

§Containment

use use_interval::Interval;

let interval = Interval::closed(1.0, 3.0);

assert!(interval.contains(1.0));
assert!(interval.contains(2.0));
assert!(interval.contains(3.0));
assert!(!interval.contains(4.0));

§Overlap and excluded endpoints

use use_interval::Interval;

let left = Interval::closed(1.0, 3.0);
let right = Interval::open(3.0, 5.0);

assert!(!left.overlaps(&right));
assert_eq!(left.intersection(&right), None);

§Intersection with an included shared endpoint

use use_interval::Interval;

let left = Interval::closed(1.0, 3.0);
let right = Interval::closed(3.0, 5.0);

assert!(left.overlaps(&right));
assert_eq!(left.intersection(&right), Some(Interval::closed(3.0, 3.0)));

§Status

use-interval is a concrete pre-1.0 crate in the RustUse math workspace. The API stays explicit and conservative so crates like use-real, use-calculus, use-probability, and use-optimization can share one small interval vocabulary without inheriting domain-specific abstractions. Small interval and bound primitives for RustUse.

Modules§

bound
Bound primitives for interval endpoints.
interval
Interval primitives and operations.

Structs§

Interval
A mathematical interval described by a lower and upper bound.

Enums§

Bound
A lower or upper bound for an interval endpoint.