refutil 0.1.0

Various utilities for reference, lifetime and memory management
Documentation
use std::ops::DerefMut;

use refutil::{RevMut, revref::RevertCheck};

struct NoChecker;

impl<D: ?Sized> RevertCheck<D> for NoChecker {
    type Snapshot = ();

    fn ensure_same(_from: &D, _other: Self::Snapshot) {}

    fn snapshot(_from: &D) -> Self::Snapshot {}
}

const _: () = {
    const fn check_same<T: DerefMut>() {
        assert!(size_of::<RevMut<T, NoChecker>>() == size_of::<T>());
        assert!(align_of::<RevMut<T, NoChecker>>() == align_of::<T>());
    }

    check_same::<&'static mut ()>();
    check_same::<std::cell::RefMut::<()>>();
    check_same::<std::sync::RwLockWriteGuard::<()>>();
};