rangex/lib.rs
1//! This crate provides clear range expression for exclusive/inclusive, forward/backward, and step great than 1 or less than -1, with index support.
2//!
3//! The most convenient way is to use the following macros:
4//!
5//! **range_inclusive!(*start*, *stop*)**
6//!
7//! This is the same as ***start*..=*stop***
8//!
9//!
10//! **range_exclusive!(*start*, *stop*)**
11//!
12//! This is the same as ***start*..*stop***
13//!
14//!
15//! **range_inclusive!(*type*, *start*, *stop*)**
16//!
17//! Creates range for *type* from *start* **through** *stop*, by **step 1**
18//!
19//!
20//! **range_inclusive!(*type*, *start*, *stop*, *step*)**
21//!
22//! Creates range for *type* from *start* **through** *stop*, by *step*
23//!
24//!
25//! **indexed_range_inclusive!(*type*, *start*, *stop*)**
26//!
27//! Creates indexed range for *type* from *start* **through** *stop*, by **step 1**
28//!
29//!
30//! **indexed_range_inclusive!(*type*, *start*, *stop*, *step*)**
31//!
32//! Creates indexed range for *type* from *start* **through** *stop*, by *step*
33//
34/// DocTest for basic_range
35/// ```
36/// use rangex::basic_range::*;
37/// use rangex::range_inclusive;
38/// let mut s = 0;
39/// // create inclusive range of u8 from 1 through 100, default step 1
40/// for v in range_inclusive!(u8, 1, 100) {
41/// s += v as u16;
42/// }
43/// println!("Sum(1..=100):{}", s);
44/// assert_eq!(s, 5050);
45/// ```
46pub mod basic_range;
47/// DocTest for indexed_range
48/// ```
49/// use rangex::indexed_range::*;
50/// use rangex::indexed_range_inclusive;
51/// let mut si = 0;
52/// let mut sv = 0;
53/// // create indexed inclusive range of u8 from 1 through 100, step 1
54/// for (i, v) in indexed_range_inclusive!(u8, 1, 100, 1) {
55/// si += i;
56/// sv += v as u16;
57/// }
58/// println!("Sum(1..=100):{}", sv);
59/// // index from 0 through 99
60/// assert_eq!(si + 100, sv as usize);
61/// assert_eq!(sv, 5050);
62/// ```
63pub mod indexed_range;
64
65mod edge;