[][src]Crate dia_range

Dia-range

Ranges for all integers

Project

Features

  • RangeType and Ops traits are implemented for all integer primitive types. So you can use Range on them.
  • Currently only Range is recommended for use. Both RangeType and Ops traits are intended for internal use only. They have to be available publicly for Range 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)));

Modules

version_info

0.10.0 (January 8th, 2020)

Structs

Error

Error

Range

Range

RangeIter

Iterator for Range

Constants

CODE_NAME

Crate code name

ID

ID of this crate

NAME

Crate name

RELEASE_DATE

Crate release date (year/month/day)

TAG

Tag, which can be used for logging...

VERSION

Crate version

Traits

Ops

Math operations

RangeType

Helper for Range

Functions

merge

Merges ranges

Type Definitions

Result

Result type used in this crate