#[cfg(not(feature = "nightly-allocator-api"))]
use allocator_api2_02::alloc::{AllocError, Allocator};
#[cfg(feature = "alloc")]
#[cfg(not(feature = "nightly-allocator-api"))]
use allocator_api2_02::boxed::Box;
#[cfg(any(test, all(feature = "alloc", not(feature = "nightly-allocator-api"))))]
use allocator_api2_02::alloc::Global;
#[cfg(not(feature = "nightly-allocator-api"))]
use crate::{
BaseAllocator, Bump, BumpScope, WithoutDealloc, WithoutShrink, alloc::AllocError as CrateAllocError,
settings::BumpAllocatorSettings, traits::BumpAllocatorCore,
};
#[cfg(feature = "alloc")]
#[cfg(not(feature = "nightly-allocator-api"))]
use crate::alloc::{BoxLike, box_like};
use super::allocator_util::{allocator_compat_wrapper, impl_allocator_via_allocator};
allocator_compat_wrapper! {
struct AllocatorApi2V02Compat for allocator_api2_02
}
#[cfg(not(feature = "nightly-allocator-api"))]
impl_allocator_via_allocator! {
self;
#[cfg(feature = "alloc")]
use {self} for crate as allocator_api2_02 impl[] Global
use {self} for allocator_api2_02 as crate impl[A, S] Bump<A, S>
where [
A: BaseAllocator<S::GuaranteedAllocated>,
S: BumpAllocatorSettings,
]
use {self} for allocator_api2_02 as crate impl[A, S] BumpScope<'_, A, S>
where [
A: BaseAllocator<S::GuaranteedAllocated>,
S: BumpAllocatorSettings,
]
use {self} for allocator_api2_02 as crate impl[A, S] &mut Bump<A, S>
where [
A: BaseAllocator<S::GuaranteedAllocated>,
S: BumpAllocatorSettings,
]
use {self} for allocator_api2_02 as crate impl[A, S] &mut BumpScope<'_, A, S>
where [
A: BaseAllocator<S::GuaranteedAllocated>,
S: BumpAllocatorSettings,
]
use {self} for allocator_api2_02 as crate impl[A: BumpAllocatorCore] WithoutShrink<A>
use {self} for allocator_api2_02 as crate impl[A: BumpAllocatorCore] WithoutDealloc<A>
}
#[cfg(not(feature = "nightly-allocator-api"))]
impl From<AllocError> for CrateAllocError {
#[inline(always)]
fn from(_: AllocError) -> Self {
CrateAllocError
}
}
#[cfg(not(feature = "nightly-allocator-api"))]
impl From<CrateAllocError> for AllocError {
#[inline(always)]
fn from(_: CrateAllocError) -> Self {
AllocError
}
}
#[cfg(feature = "alloc")]
#[cfg(not(feature = "nightly-allocator-api"))]
impl<T: ?Sized, A: Allocator> box_like::Sealed for Box<T, A> {
type T = T;
type A = A;
unsafe fn from_raw_in(ptr: *mut Self::T, allocator: Self::A) -> Self {
unsafe { Box::from_raw_in(ptr, allocator) }
}
}
#[cfg(feature = "alloc")]
#[cfg(not(feature = "nightly-allocator-api"))]
impl<T: ?Sized, A: Allocator> BoxLike for Box<T, A> {}