vivian-essentials 0.1.0

vivian's essential utilities
Documentation
  • Coverage
  • 9.09%
    1 out of 11 items documented1 out of 7 items with examples
  • Size
  • Source code size: 8.92 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.6 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • spring4175

test badge rust badge license badge

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:

[dependencies]
vivian-essentials = "0.1"

API

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.