humanize/lib.rs
1// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
2// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
4// option. This file may not be copied, modified, or distributed
5// except according to those terms.
6
7//! # Humanize
8//!
9//! Make your user interface more human friendly!
10//!
11//! This library provides functionality for both formatting values
12//! into human friendly forms as well as parsing human input to get
13//! back likely values.
14//!
15//! _Actually, the formatting isn't implemented yet. Contributions
16//! are welcome!_
17//!
18//! This library is inspired by many other things, including:
19//!
20//! * Python's [humanize library].
21//! * JavaScript's [moment.js].
22//! * The ['at' command]'s input parsing.
23//!
24//! Contributions extending our functionality are welcome, as are
25//! contributions that add support for additional languages.
26//!
27//! # Human-friendly Parsing
28//!
29//! When dealing with humans, you often want them to be able to
30//! input values in a flexible manner. For example, you might want
31//! to be able to input a `bool` using text like `"on"`, `"off"`,
32//! `"yes"`, `"no"` or perhaps even `"nope"`.
33//!
34//! ```
35//! let enabled = humanize::parse::<bool>("on").unwrap_or(false);
36//! assert_eq!(enabled, true);
37//! ```
38//!
39//! # Ideas for the Future
40//!
41//! * Actually implement formatting.
42//!
43//! [humanize library]: https://pypi.python.org/pypi/humanize
44//! [moment.js]: http://momentjs.com/
45//! ['at' command]: http://www.computerhope.com/unix/uat.htm
46
47#![warn(missing_docs)]
48#![deny(trivial_numeric_casts,
49 unsafe_code, unstable_features,
50 unused_import_braces, unused_qualifications)]
51
52#[macro_use]
53extern crate language_tags;
54
55pub mod boolean;
56mod parser;
57
58pub use parser::{parse, parse_with_language, Parse};