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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! Simple truthy/falsy string evaluation for Rust — part of the
//! cross-language **to-be** family.
//!
//! **to-be** classifies strings commonly found in configuration and
//! environment variables — such as `"yes"`, `"no"`, `"true"`, and
//! `"off"` — as *truthy* (recognised), *truey* (interpreted as true),
//! or *falsey* (interpreted as false). Strings that are not recognised
//! yield `None` from [`string_is_truthy`] and the [`Truthy::is_truthy`]
//! trait method.
//!
//! The library is implemented in several languages; **to-be.Rust** is the
//! Rust port.
//!
//! # Terminology
//!
//! * *truthy* — the string can be interpreted as having a boolean meaning;
//! * *truey* — the string is interpreted as true;
//! * *falsey* — the string is interpreted as false.
//!
//! Note that [`string_is_falsey`] and [`string_is_truey`] answer narrower
//! questions than [`string_is_truthy`]: an empty string is neither truey
//! nor falsey, so both helper functions return `false`.
//!
//! # Installation
//!
//! Reference in **Cargo.toml** in the usual way:
//!
//! ```toml
//! to-be = { version = "0" }
//! ```
//!
//! # Components
//!
//! ## Functions
//!
//! * [`string_is_falsey`] — is the trimmed string a recognised falsey term;
//! * [`string_is_truey`] — is the trimmed string a recognised truey term;
//! * [`string_is_truthy`] — full three-way classification using
//! stock terms;
//! * [`string_is_truthy_with`] — classification against custom [`Terms`];
//! * [`stock_term_strings`] — obtain the built-in term tables as [`Terms`];
//!
//! ## Types
//!
//! * [`Terms`] — selects stock or custom comparison strings;
//! * [`Truthy`] — trait providing `is_truthy()`, `is_truey()`, and
//! `is_falsey()` on supported types;
//!
//! # Examples
//!
//! ```
//! use to_be::Truthy as _;
//!
//! assert_eq!(Some(false), "no".is_truthy());
//! assert_eq!(Some(true), "True".is_truthy());
//! assert_eq!(None, "orange".is_truthy());
//! ```
//!
//! Further examples are provided in the repository **examples** directory
//! and in the project
//! [README](https://github.com/synesissoftware/to-be.Rust).
// lib.rs
pub use ;
pub use Terms;
pub use Truthy;
// ///////////////////////////// end of file //////////////////////////// //