nlib 0.1.3

Nate's library. Various things or macro patterns I use to aid in more succint Rust programming.
Documentation
// Copyright 2025 Nathan Sizemore <nathanrsizemore@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at http://mozilla.org/MPL/2.0/.

#[macro_export]
macro_rules! ok_or {
    // With an error binding: ok_or!(expr, |e| { ... }) or ok_or!(expr, |e| expr)
    ($expr:expr, |$e:ident| $($on_err:tt)*) => {{
        match $expr {
            Ok(v) => v,
            Err($e) => { $($on_err)* },
        }
    }};
    // Without an error binding: ok_or!(expr, { ... })
    ($expr:expr, $on_err:block) => {{
        match $expr {
            Ok(v) => v,
            Err(_) => $on_err,
        }
    }};
}

#[macro_export]
macro_rules! some_or {
    // Fallback: some_or!(opt, { ... }) or some_or!(opt, expr)
    ($expr:expr, $($fallback:tt)*) => {{
        match $expr {
            Some(v) => v,
            None => { $($fallback)* },
        }
    }};
}