use std::cell;
use crate::{
depot::{self, index},
mem::{self, slot},
};
unsafe impl<'a, T, M> depot::raw::Project<(), T> for &'a slot::Storage<T, M> {
type Output = &'a T;
unsafe fn project(self, _: ()) -> Self::Output {
unsafe { mem::raw::project(self) }
}
}
unsafe impl<'a, T, M> depot::raw::Project<(), T> for &'a mut slot::Storage<T, M> {
type Output = mem::raw::Occupied<'a, T>;
unsafe fn project(self, _: ()) -> Self::Output {
unsafe { mem::raw::occupy(self) }
}
}
unsafe impl<'a, T, M> depot::raw::Project<(), index::Vacant<T>> for &'a mut slot::Storage<T, M> {
type Output = mem::raw::Vacant<'a, T>;
unsafe fn project(self, _: ()) -> Self::Output {
unsafe { mem::raw::vacancy(self) }
}
}
unsafe impl<'a, T, const N: usize> depot::raw::Project<usize> for &'a [T; N] {
type Output = &'a T;
unsafe fn project(self, index: usize) -> Self::Output {
unsafe { self.get_unchecked(index) }
}
}
unsafe impl<'a, T, const N: usize> depot::raw::Project<usize> for &'a mut [T; N] {
type Output = &'a mut T;
unsafe fn project(self, index: usize) -> Self::Output {
unsafe { self.get_unchecked_mut(index) }
}
}
unsafe impl<'a, T> depot::raw::Project<usize> for &'a mut [T] {
type Output = &'a mut T;
unsafe fn project(self, index: usize) -> Self::Output {
unsafe { self.get_unchecked_mut(index) }
}
}
unsafe impl<K: crate::depot::raw::Key> crate::depot::raw::Address for K {
fn index(self) -> usize {
crate::depot::raw::Key::index(self)
}
}
unsafe impl<I: Copy + Eq> crate::depot::raw::Link for Option<I> {
type Item = I;
const NONE: Self = None;
fn item(self) -> Option<I> {
self
}
unsafe fn some(item: I) -> Self {
Some(item)
}
}
unsafe impl crate::depot::raw::Link for u16 {
type Item = Self;
const NONE: Self = Self::MAX;
fn item(self) -> Option<Self> {
(self != Self::NONE).then_some(self)
}
unsafe fn some(item: Self) -> Self {
item
}
}
unsafe impl crate::depot::raw::Link for u32 {
type Item = Self;
const NONE: Self = Self::MAX;
fn item(self) -> Option<Self> {
(self != Self::NONE).then_some(self)
}
unsafe fn some(item: Self) -> Self {
item
}
}
unsafe impl crate::depot::raw::ChainCount for u32 {
const EMPTY: Self = 0;
fn storage(count: &cell::Cell<Self>) -> Option<&cell::Cell<u32>> {
Some(count)
}
}
unsafe impl crate::depot::raw::ChainCount for () {
const EMPTY: Self = ();
fn storage(_: &cell::Cell<Self>) -> Option<&cell::Cell<u32>> {
None
}
}
mod key;
mod rounds;
mod word;
unsafe impl crate::depot::raw::Compact for u32 {
const MAX: u32 = u32::MAX;
fn into_raw(self) -> u32 {
self
}
unsafe fn from_raw(raw: u32) -> Self {
raw
}
}
mod exacts;
mod tagged;