[![test badge]][test link] [![rust badge]][rust link] [![license badge]][license link] # vivian's essential utilities Some nifty utilities to make some mostly-already-easy tasks easier. Read the docs for all the methods. ## Installation The minimum supported version is Rust 1.41.0. `Cargo.toml`: ```toml [dependencies] vivian-essentials = "0.1" ``` ## API ### guard Guard against something that should be true, returning an error if it's not: ```rust essentials::guard(some_condition())?; ``` This is useful for `?` heavy code, and is especially useful with crates like `snafu`: ```rust use crate::error::UserNotVerified; use snafu::ResultExt; essentials::guard(user.is_verified()).context(UserNotVerified)? ``` ### io Prompt a user for something with a message: ```rust let email = essentials::prompt("What is your email address?\n> ")?; ``` ### sugar If you miss ternaries, then this is one of the closest ways you can get without using a macro: ```rust let discount = essentials::tern(age > 65, Discount::Senior, Discount::Regular); ``` ## License ISC. [license badge]: https://img.shields.io/github/license/vivianhellyer/essentials?style=for-the-badge [license link]: https://opensource.org/licenses/ISC [rust badge]: https://img.shields.io/badge/Rust-1.41-93450a?style=for-the-badge [rust link]: https://blog.rust-lang.org/2020/01/30/Rust-1.41.0.html [test badge]: https://img.shields.io/github/workflow/status/vivianhellyer/essentials/Tests/master?style=for-the-badge [test link]: https://github.com/vivianhellyer/essentials/actions