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/.

/// Debug-only assertion that a raw pointer is not null.
///
/// Expands to a `debug_assert!` that checks `!$ptr.is_null()`.
/// Like `debug_assert!`, this **only runs in non-optimized builds**
/// (i.e., when `debug_assertions` are enabled) and is a no-op in
/// release builds.
///
/// Two forms are supported:
/// 1) `debug_assert_not_null!(ptr);` — prints a default message with the
///    pointer expression’s name via `stringify!`.
/// 2) `debug_assert_not_null!(ptr, "custom {}", msg);` — custom message.
///
/// ### Parameters
/// - `$ptr`: an expression of type `*const T` or `*mut T`.
///
/// ### Example
/// ```rust
/// # use std::ptr;
/// # use your_crate::debug_assert_not_null;
/// let p: *mut u8 = 0x1 as *mut u8;
/// debug_assert_not_null!(p);
///
/// let q: *const u8 = ptr::null();
/// // This will panic in debug builds:
/// // debug_assert_not_null!(q, "q must be valid before FFI call");
/// ```
#[macro_export]
macro_rules! debug_assert_not_null {
    ($ptr:expr $(,)?) => {
        debug_assert!(
            !$ptr.is_null(),
            "pointer `{}` was null",
            stringify!($ptr)
        );
    };
    ($ptr:expr, $($arg:tt)+) => {
        debug_assert!(!$ptr.is_null(), $($arg)+);
    };
}