Expand description
§vivian’s essential utilities
Some nifty utilities to make some mostly-already-easy tasks easier.
§Installation
Cargo.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:
essentials::guard(some_condition())?;This is useful for ? heavy code, and is especially useful with crates like
snafu:
ⓘ
use crate::error::UserNotVerified;
use snafu::ResultExt;
essentials::guard(user.is_verified()).context(UserNotVerified)?§io
Prompt a user for something with a message:
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:
let discount = essentials::tern(age > 65, Discount::Senior, Discount::Regular);§License
ISC.