#![allow(unused_variables)]
use crate::*;
use crate::meta::*;
use core::alloc::Layout;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Null;
impl Meta for Null {
type Error = ();
const MAX_ALIGN : Alignment = Alignment::MAX;
const MAX_SIZE : usize = usize::MAX;
const ZST_SUPPORTED : bool = true;
}
impl ZstSupported for Null {}
unsafe impl Stateless for Null {}
unsafe impl thin::Alloc for Null {
fn alloc_uninit(&self, size: usize) -> Result<AllocNN, Self::Error> { Err(()) }
}
unsafe impl thin::Free for Null {
#[track_caller] #[inline(never)] unsafe fn free(&self, ptr: AllocNN) {
unsafe { ub!("bug: undefined behavior: {ptr:?} does not belong to `self` as the Null allocator can't allocate anything to free in the first place") }
}
}
unsafe impl thin::Realloc for Null {
const CAN_REALLOC_ZEROED : bool = true;
unsafe fn realloc_uninit(&self, ptr: AllocNN, new_size: usize) -> Result<AllocNN, Self::Error> { Err(()) }
unsafe fn realloc_zeroed(&self, ptr: AllocNN, new_size: usize) -> Result<AllocNN, Self::Error> { Err(()) }
}
unsafe impl thin::SizeOf for Null {}
unsafe impl thin::SizeOfDebug for Null {
#[track_caller] #[inline(never)] unsafe fn size_of_debug(&self, ptr: AllocNN) -> Option<usize> {
unsafe { ub!("bug: undefined behavior: {ptr:?} does not belong to `self` as the Null allocator can't allocate anything to query in the first place") }
}
}
unsafe impl fat::Alloc for Null {
fn alloc_uninit(&self, layout: Layout) -> Result<AllocNN, Self::Error> { Err(()) }
fn alloc_zeroed(&self, layout: Layout) -> Result<AllocNN0, Self::Error> { Err(()) }
}
unsafe impl fat::Free for Null {
#[track_caller] #[inline(never)] unsafe fn free(&self, ptr: AllocNN, layout: Layout) {
unsafe { ub!("bug: undefined behavior: {ptr:?} does not belong to `self` as the Null allocator can't allocate anything to free in the first place") }
}
}
unsafe impl fat::Realloc for Null {
unsafe fn realloc_uninit(&self, ptr: AllocNN, old_layout: Layout, new_layout: Layout) -> Result<AllocNN, Self::Error> { Err(()) }
unsafe fn realloc_zeroed(&self, ptr: AllocNN, old_layout: Layout, new_layout: Layout) -> Result<AllocNN, Self::Error> { Err(()) }
}
#[test] fn thin_alignment() { thin::test::alignment(Null) }
#[test] fn thin_nullable() { thin::test::nullable(Null) }
#[test] fn thin_size() { thin::test::size_exact_alloc(Null) }
#[test] fn thin_uninit() { unsafe { thin::test::uninit_alloc_unsound(Null) } }
#[test] fn thin_uninit_realloc() { thin::test::uninit_realloc(Null) }
#[test] fn thin_zeroed() { thin::test::zeroed_alloc(Null) }
#[test] fn thin_zeroed_realloc() { thin::test::zeroed_realloc(Null) }