Expand description
§Decription
A crate that provides some simple and maybe stupid or useful tools
§Example
use std::collections::HashMap;
use stupid_utils::prelude::*;
let a = HashMap::new().mutable_init(|m| {
m.insert(1, 4.box_up());
m.insert(
2,
Some(9)
.map_value(|v| match v {
Some(v) => v,
None => 3,
})
.box_up(),
);
let cond = true;
m.insert(cond.select(3, 4), select(cond, 3, 4).box_up());
});
let b = {
let mut m = HashMap::new();
m.insert(1, Box::new(4));
m.insert(
2,
Box::new({
let v = Some(9);
match v {
Some(v) => v,
None => 3,
}
}),
);
let cond = true;
m.insert(if cond { 3 } else { 4 }, Box::new(if cond { 3 } else { 4 }));
m
};
assert_eq!(a, b);
Modules§
- arc_
mutex - arc_
mutex_ new - box_up
- currying
- curry a function/closure
- defer
Non- disable_non_zerocost
- disabled
- dot_
debug - dot_
drop - dot_ref
- extend_
map_ iter Non- disable_non_zerocost
- find_
in_ vec - fn_
apply fn_apply
- call a function by
.apply(arg)
- functional_
trait functional_trait
- if_
iter_ remains Non- disable_non_zerocost
- instant_
run - just_
provide - map_
value - mutable_
init - mutex_
lock_ and_ unwrap - one_
or_ many - option_
to_ result - prelude
- print_
on_ drop - provide
- rebind
- rebind a ident to mut or non-mut
- result_
to_ option - select
- set_mut
- short_
unwrap - stack_
struct - tuple_
index tuple_index
- index a tuple by specific types
- wrap_
in_ whatever
Macros§
- curry
- curry a function/closure
- disable
- disables a identfier
- instant_
run - mutable
- rebind a ident to mut
- nonmutable
- rebind a ident to non-mut