0.10.0 |
|
---|---|
0.9.0 |
|
0.8.0 |
|
#6 in #dia
25 downloads per month
Used in bailamos
27KB
448 lines
Dia-range
- Version:
0.10.0
(January 8th, 2020)- This project follows Semantic Versioning 2.0.0
- License: Nice License 1.0.0
- Repository: https://bitbucket.org/haibison/dia-range
- Crate: https://crates.io/crates/dia-range
- Documentation: https://docs.rs/dia-range
lib.rs
:
Dia-range
Ranges for all integers
Project
- Repository: https://bitbucket.org/haibison/dia-range
- License: Nice License 1.0.0 (see LICENSE file at root directory of
master
branch) - This project follows Semantic Versioning 2.0.0
Features
RangeType
andOps
traits are implemented for all integer primitive types. So you can useRange
on them.- Currently only
Range
is recommended for use. BothRangeType
andOps
traits are intended for internal use only. They have to be available publicly forRange
to be valid, but they are sealed.
Notes
The crate uses #![no_std]
by default. Documentation is built with all features, which include std
. If you see some components from
std
crate, you have to use that feature.
Examples
use dia_range::Range;
// First type i16 is for indexes; second type (u16) is for estimating range size.
// You can ignore second type, the compiler will figure it out.
let mut range: Range<i16, _> = Range::new(50, 100);
assert!(range.contains(&99));
assert!(range.expand(101));
assert!(range.expand(103) == false);
assert!(range.contains(&101));
assert_eq!(range.estimate_size(), 52);
// Merging
assert_eq!(range.merge(&Range::new(100, 150)), Some(Range::new(50, 150)));