7 releases
0.1.6 | Feb 19, 2024 |
---|---|
0.1.5 | Feb 19, 2024 |
#4 in #readability
24 downloads per month
22KB
216 lines
GenZTools
Making Rust more accessible and readable for the upcoming generation of Rust engineers
Examples:
Before:
let is_logged_in = get_user().await.ok().flatten().is_some();
After:
let is_logged_in = get_user().await.bet().on_a_stack().no_cap();
or
Before:
let new_thing = my_opt.map(|x| transform(x)).unwrap_or_default();
After:
let new_thing = my_opt.glow_up(|x| transform(x)).on_god_or_basic();
lib.rs
:
Making Rust more accessible and readable for the upcoming generation of Rust engineers
Provides alternative method names for common Option
and Result
methods
Examples
use genztools::*;
let user_from_db: Result<Option<&str>, &str> = Ok(Some("username"));
// let is_logged_in = user_from_db.ok().flatten().is_some();
let is_logged_in = user_from_db.bet().on_a_stack().no_cap();
let known_failure: Result<(), &str> = Err("sussy af fr fr");
// assert_eq!(known_failure.unwrap_err(), "sussy af fr fr");
assert_eq!(known_failure.big_yikes(), "sussy af fr fr");
let my_opt: Option<i64> = Some(-3);
// let num = my_opt.map(|x| x * x).unwrap_or_default();
let num = my_opt.glow_up(|x| x * x).on_god_or_basic();