|
1 | 1 | // SPDX-License-Identifier: MPL-2.0
|
2 | 2 |
|
3 |
| -//! Ranges are constraints defining sets of versions. |
| 3 | +//! As its name suggests, the [VersionSet] trait describes sets of versions. |
4 | 4 | //!
|
5 |
| -//! Concretely, those constraints correspond to any set of versions |
6 |
| -//! representable as the concatenation, union, and complement |
7 |
| -//! of the ranges building blocks. |
| 5 | +//! One needs to define |
| 6 | +//! - the associate type for versions, |
| 7 | +//! - two constructors for the empty set and a singleton set, |
| 8 | +//! - the complement and intersection set operations, |
| 9 | +//! - and a function to evaluate membership of versions. |
8 | 10 | //!
|
9 |
| -//! Those building blocks are: |
10 |
| -//! - [none()](Range::none): the empty set |
11 |
| -//! - [any()](Range::any): the set of all possible versions |
12 |
| -//! - [exact(v)](Range::exact): the set containing only the version v |
13 |
| -//! - [higher_than(v)](Range::higher_than): the set defined by `v <= versions` |
14 |
| -//! - [strictly_lower_than(v)](Range::strictly_lower_than): the set defined by `versions < v` |
15 |
| -//! - [between(v1, v2)](Range::between): the set defined by `v1 <= versions < v2` |
| 11 | +//! Two functions are automatically derived, thanks to the mathematical properties of sets. |
| 12 | +//! You can overwrite those implementations, but we highly recommend that you don't, |
| 13 | +//! except if you are confident in a correct implementation that brings much performance gains. |
| 14 | +//! |
| 15 | +//! It is also extremely important that the `Eq` trait is correctly implemented. |
| 16 | +//! In particular, you can only use `#[derive(Eq, PartialEq)]` if `Eq` is strictly equivalent to the |
| 17 | +//! structural equality, i.e. if versions have canonical representations. |
| 18 | +//! Such problems may arise if your implementations of `complement()` and `intersection()` do not |
| 19 | +//! return canonical representations so be careful there. |
16 | 20 |
|
17 | 21 | use std::fmt::{Debug, Display};
|
18 | 22 |
|
|
0 commit comments