Some nifty utilities to make some mostly-already-easy tasks easier.
[dependencies] vivian-essentials = "0.1"
Read the docs for all the functionality.
Guard against something that should be true, returning an error if it's not:
This is useful for
? heavy code, and is especially useful with crates like
use crate::error::UserNotVerified; use snafu::ResultExt; essentials::guard(user.is_verified()).context(UserNotVerified)?
Prompt a user for something with a message:
let email = essentials::prompt("What is your email address?\n> ")?;
If you miss ternaries, then this is one of the closest ways you can get without using a macro:
let discount = essentials::tern(age > 65, Discount::Senior, Discount::Regular);