start with pointer

This commit is contained in:
nora 2022-04-03 13:16:30 +02:00
parent 062e2f7ee2
commit 6042f4702d
3 changed files with 209 additions and 6 deletions

47
src/strategies.rs Normal file
View file

@ -0,0 +1,47 @@
use crate::StuffingStrategy;
unsafe impl StuffingStrategy for () {
type Extra = ();
fn is_extra(_data: usize) -> bool {
false
}
fn stuff_extra(_inner: Self::Extra) -> usize {
0
}
fn extract_extra(_data: usize) -> Self::Extra {
()
}
}
#[cfg(test)]
pub mod test_strategies {
use crate::StuffingStrategy;
use std::fmt::{Debug, Formatter};
pub struct HasDebug;
impl Debug for HasDebug {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str("hello!")
}
}
unsafe impl StuffingStrategy for HasDebug {
type Extra = Self;
fn is_extra(data: usize) -> bool {
data == usize::MAX
}
fn stuff_extra(_inner: Self::Extra) -> usize {
usize::MAX
}
fn extract_extra(_data: usize) -> Self::Extra {
Self
}
}
}