to_be/lib.rs
1//! Simple truthy/falsy string evaluation for Rust — part of the
2//! cross-language **to-be** family.
3//!
4//! **to-be** classifies strings commonly found in configuration and
5//! environment variables — such as `"yes"`, `"no"`, `"true"`, and
6//! `"off"` — as *truthy* (recognised), *truey* (interpreted as true),
7//! or *falsey* (interpreted as false). Strings that are not recognised
8//! yield `None` from [`string_is_truthy`] and the [`Truthy::is_truthy`]
9//! trait method.
10//!
11//! The library is implemented in several languages; **to-be.Rust** is the
12//! Rust port.
13//!
14//! # Terminology
15//!
16//! * *truthy* — the string can be interpreted as having a boolean meaning;
17//! * *truey* — the string is interpreted as true;
18//! * *falsey* — the string is interpreted as false.
19//!
20//! Note that [`string_is_falsey`] and [`string_is_truey`] answer narrower
21//! questions than [`string_is_truthy`]: an empty string is neither truey
22//! nor falsey, so both helper functions return `false`.
23//!
24//! # Installation
25//!
26//! Reference in **Cargo.toml** in the usual way:
27//!
28//! ```toml
29//! to-be = { version = "0" }
30//! ```
31//!
32//! # Components
33//!
34//! ## Functions
35//!
36//! * [`string_is_falsey`] — is the trimmed string a recognised falsey term;
37//! * [`string_is_truey`] — is the trimmed string a recognised truey term;
38//! * [`string_is_truthy`] — full three-way classification using
39//! stock terms;
40//! * [`string_is_truthy_with`] — classification against custom [`Terms`];
41//! * [`stock_term_strings`] — obtain the built-in term tables as [`Terms`];
42//!
43//! ## Types
44//!
45//! * [`Terms`] — selects stock or custom comparison strings;
46//! * [`Truthy`] — trait providing `is_truthy()`, `is_truey()`, and
47//! `is_falsey()` on supported types;
48//!
49//! # Examples
50//!
51//! ```
52//! use to_be::Truthy as _;
53//!
54//! assert_eq!(Some(false), "no".is_truthy());
55//! assert_eq!(Some(true), "True".is_truthy());
56//! assert_eq!(None, "orange".is_truthy());
57//! ```
58//!
59//! Further examples are provided in the repository **examples** directory
60//! and in the project
61//! [README](https://github.com/synesissoftware/to-be.Rust).
62
63// lib.rs
64
65mod constants;
66mod impls;
67mod parse;
68mod terms;
69mod truthy;
70
71pub use parse::{
72 os_string_is_truthy,
73 stock_term_strings,
74 string_is_falsey,
75 string_is_truey,
76 string_is_truthy,
77 string_is_truthy_with,
78};
79pub use terms::Terms;
80pub use truthy::Truthy;
81
82
83// ///////////////////////////// end of file //////////////////////////// //