use core::fmt;
use core::marker::PhantomData;
use crate::allocator::Allocator;
use crate::inline_key::InlineKeyStrategy;
use crate::inline_key::sealed::{InlineKeySource, Sealed};
pub trait LeafAnnex: Default + Send + Sync {
fn split(&mut self, right: &mut Self);
fn merge(&mut self, right: Self);
fn release(self, alloc: &impl Allocator);
}
impl LeafAnnex for () {
#[inline(always)]
fn split(&mut self, _right: &mut Self) {}
#[inline(always)]
fn merge(&mut self, _right: Self) {}
#[inline(always)]
fn release(self, _alloc: &impl Allocator) {}
}
pub struct WithLeafAnnex<S, L>(PhantomData<fn() -> (S, L)>);
impl<S, L> WithLeafAnnex<S, L> {
#[must_use]
pub const fn new() -> Self {
Self(PhantomData)
}
}
impl<S, L> Clone for WithLeafAnnex<S, L> {
fn clone(&self) -> Self {
*self
}
}
impl<S, L> Copy for WithLeafAnnex<S, L> {}
impl<S, L> Default for WithLeafAnnex<S, L> {
fn default() -> Self {
Self::new()
}
}
impl<S, L> fmt::Debug for WithLeafAnnex<S, L> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("WithLeafAnnex")
}
}
impl<K, S: InlineKeyStrategy<K>, L: LeafAnnex> Sealed<K> for WithLeafAnnex<S, L> {
const SOURCE: InlineKeySource<K> = S::SOURCE;
type Config = S::Config;
}
impl<K, S: InlineKeyStrategy<K>, L: LeafAnnex> InlineKeyStrategy<K> for WithLeafAnnex<S, L> {
type LeafAnnex = L;
}