allocator-suite 0.1.7

Allocator Suite for various allocation types
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::extensions::prelude::*;

/// Useful extensions.
pub(crate) trait PointerMutExt<T>: PointerExt<T> {
    /// Mutable reference.
    fn mutable_reference<'a>(self) -> &'a mut T;
}

impl<T> PointerMutExt<T> for *mut T {
    #[inline(always)]
    fn mutable_reference<'a>(self) -> &'a mut T {
        debug_assert!(self.is_not_null(), "null pointers can not be derefenced");

        unsafe { &mut *self }
    }
}