#![cfg_attr(not(test), no_std)]
use allocator_api2::alloc::Allocator;
use combinator::{Cond, Fallback};
use core::{alloc::Layout, ptr::NonNull};
pub mod alloc;
pub mod combinator;
pub trait AwareAllocator: Allocator {
fn owns(&self, ptr: NonNull<u8>, layout: Layout) -> bool;
}
pub trait Allocandrescu: Sized {
fn cond<F>(self, pred: F) -> Cond<Self, F>
where
F: Fn(Layout) -> bool,
{
Cond::new(self, pred)
}
fn fallback<S>(self, secondary: S) -> Fallback<Self, S>
where
Self: AwareAllocator,
S: Allocator,
{
Fallback::new(self, secondary)
}
}
impl<A: Allocator> Allocandrescu for A {}