mirror of
https://github.com/Noratrieb/stuff.git
synced 2026-01-15 17:05:08 +01:00
make backend generic
This commit is contained in:
parent
3e11ae0f17
commit
d144819eb0
3 changed files with 68 additions and 45 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use crate::StuffingStrategy;
|
||||
|
||||
unsafe impl StuffingStrategy for () {
|
||||
unsafe impl StuffingStrategy<usize> for () {
|
||||
type Extra = ();
|
||||
|
||||
fn is_extra(_data: usize) -> bool {
|
||||
|
|
@ -16,6 +16,14 @@ unsafe impl StuffingStrategy for () {
|
|||
}
|
||||
|
||||
unsafe fn extract_extra(_data: usize) -> Self::Extra {}
|
||||
|
||||
fn stuff_ptr(addr: usize) -> usize {
|
||||
addr
|
||||
}
|
||||
|
||||
fn extract_ptr(inner: usize) -> usize {
|
||||
inner
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
@ -26,7 +34,7 @@ pub(crate) mod test_strategies {
|
|||
macro_rules! impl_usize_max_zst {
|
||||
($ty:ident) => {
|
||||
// this one lives in usize::MAX
|
||||
unsafe impl StuffingStrategy for $ty {
|
||||
unsafe impl StuffingStrategy<usize> for $ty {
|
||||
type Extra = Self;
|
||||
|
||||
fn is_extra(data: usize) -> bool {
|
||||
|
|
@ -42,6 +50,14 @@ pub(crate) mod test_strategies {
|
|||
unsafe fn extract_extra(_data: usize) -> Self::Extra {
|
||||
$ty
|
||||
}
|
||||
|
||||
fn stuff_ptr(addr: usize) -> usize {
|
||||
addr
|
||||
}
|
||||
|
||||
fn extract_ptr(inner: usize) -> usize {
|
||||
inner
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue