vivian-essentials 0.1.0

vivian's essential utilities
Documentation
//! # vivian's essential utilities
//!
//! Some nifty utilities to make some mostly-already-easy tasks easier.
//!
//! ## Installation
//!
//! `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! vivian-essentials = "0.1"
//! ```
//!
//! ## API
//!
//! Read the docs for all the functionality.
//!
//! ### guard
//!
//! Guard against something that should be true, returning an error if it's not:
//!
//! ```rust
//! # fn some_condition() -> bool { true }
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! essentials::guard(some_condition())?;
//! # Ok(()) }
//! ```
//!
//! This is useful for `?` heavy code, and is especially useful with crates like
//! `snafu`:
//!
//! ```rust,ignore
//! use crate::error::UserNotVerified;
//! use snafu::ResultExt;
//!
//! essentials::guard(user.is_verified()).context(UserNotVerified)?
//! ```
//!
//! ### io
//!
//! Prompt a user for something with a message:
//!
//! ```rust,no_run
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let email = essentials::prompt("What is your email address?\n> ")?;
//! # Ok(()) }
//! ```
//!
//! ### sugar
//!
//! If you miss ternaries, then this is one of the closest ways you can get without
//! using a macro:
//!
//! ```rust
//! # #[derive(Debug, Eq, PartialEq)] enum Discount { Regular, Senior }
//! # let age = 50i32;
//! let discount = essentials::tern(age > 65, Discount::Senior, Discount::Regular);
//! # assert_eq!(Discount::Regular, discount);
//! ```
//!
//! ## License
//!
//! ISC.

pub mod guard;
pub mod io;
pub mod prelude;
pub mod sugar;

pub use guard::guard;
pub use io::prompt;
pub use sugar::tern;