Crates.io | confused |
lib.rs | confused |
version | 0.1.2 |
source | src |
created_at | 2024-09-10 12:07:21.355968 |
updated_at | 2024-09-10 12:25:32.626156 |
description | treat scary functions with the respect they deserve |
homepage | |
repository | |
max_upload_size | |
id | 1370318 |
size | 5,360 |
Do you ever find yourself using a function that intimidates you? Are there functions so terrifying, mere comments do not sufficiently warn unwitting callers of its infinite complexity and unknowability?
With the confusion!()
and confused!()
macros, you can easily mark a scary function as such:
fn main() -> Result<(), ()> {
if scary_function(666)?????????? {
println!("oh shit, oh fuck");
}
Ok(())
}
fn scary_function(evil_number: u16) -> confusion!(10, bool) {
confused!(10, evil_number == 666)
}
confusion!(n, ok, err = ())
n
is the depth of the Result<...>
chain
ok
is the type of the final Ok
value
err
is an optional Err
type, if you actually want to use this for error handling
confused!(n, expr)
n
is the depth of the Ok(...)
chain
expr
is the final result