1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! Both tariffs and CDRs can be linted - a term borrowed from software development where
//! linting is the act of flagging common errors, bugs, dangerous constructs and
//! stylistic flaws in a some code or data.
//!
//! The term originates from the English word `lint`, the tiny pieces of fiber and fluff that are
//! shed by clothing and trapped in a washing machines filter.
//!
//! Use [`tariff::lint`](crate::tariff::lint) to lint a tariff.
pub mod tariff;
/// Lint the given tariff and return a report of any `Warning`s found.
pub(crate) fn tariff(tariff: &crate::tariff::Versioned<'_>) -> tariff::Report {
tariff::lint(tariff)
}
/// A container for items in a list that can be linted as an invalid item.
enum Item<T> {
/// The item is invalid and can be ignored.
Invalid,
/// The item is valid and can be further inspected.
Valid(T),
}
/// Convert an `Option<T>` into an `Item<T>`.
impl<T> From<Option<T>> for Item<T> {
fn from(value: Option<T>) -> Self {
match value {
Some(v) => Item::Valid(v),
None => Item::Invalid,
}
}
}
/// Convert an `Item<T>` into an `Option<T>`.
impl<T> From<Item<T>> for Option<T> {
fn from(value: Item<T>) -> Self {
match value {
Item::Invalid => None,
Item::Valid(v) => Some(v),
}
}
}