weirdboi_utils

Crates.ioweirdboi_utils
lib.rsweirdboi_utils
version0.2.0
created_at2025-12-28 02:01:35.081981+00
updated_at2025-12-28 02:01:35.081981+00
descriptionA collection of utility macros
homepage
repositoryhttps://weirdboi.dev/libraries/weirdboi-utils
max_upload_size
id2008138
size21,475
Louis Capitanchik (Commander-lol)

documentation

README

Utility Macros

Usage

Add to your project

[dependencies]
# There is not presently a crates.io release
weirdboi_utils = { git = "https://weirdboi.dev/libraries/weirdboi-utils.git", rev = "put-a-revision-here" }

Build Collections

Hashmaps

Build hashmaps in-place with the hashmap macro

let some_output = function_call("string", 23, hashmap! {
    "key" => 123,
    "another_key" => 456
});

VecDeque

Similar to built in vec!, but for VecDeque

let my_deq = dequeue![1, 2, 3];

Safe Unwrapping

When you want to simply do nothing and cease further execution without a panic, the convenience some! and ok! macros are handy:

fn do_something_without_fail(value: Result<A, B>, maybe: Option<F>) {
    let value = ok!(value);
    let maybe = some!(maybe);

    println!("Value was OK and maybe was SOME");
}

Alternatively, in a loop you can skip the rest of the current iteration instead of ending executino entirely:

fn do_many_things(list: impl Iter<Item = Option<F>>) {
    for item in list {
        let current = some!(item; continue);
        println!("Found SOME: {}", current);
    }
}

Finally, if the function has a return type then you should specify a default value to return:

fn get_widget(maybe: Result<A, B>) -> i32 {
    let maybe = ok!(maybe; -1); // Returns "-1" from the function if maybe is Err(_)
}
Commit count: 0

cargo fmt