add pointer tag

This commit is contained in:
nora 2022-04-10 15:06:37 +02:00
parent 3209133840
commit c54e5531aa
3 changed files with 18 additions and 2 deletions

View file

@ -13,8 +13,6 @@ categories = ["data-structures", "memory-management", "no-std"]
include = ["Cargo.toml", "LICENSE", "src", "README.md"] include = ["Cargo.toml", "LICENSE", "src", "README.md"]
rust-version = "1.34.2" rust-version = "1.34.2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
sptr = "0.3.1" sptr = "0.3.1"

View file

@ -92,6 +92,7 @@ extern crate alloc; // we want that for tests so we can use `Box`
mod backend; mod backend;
mod strategy; mod strategy;
mod tag;
use core::{ use core::{
fmt::{Debug, Formatter}, fmt::{Debug, Formatter},

17
src/tag.rs Normal file
View file

@ -0,0 +1,17 @@
use core::marker::PhantomData;
use crate::Backend;
pub struct TaggedPtr<T, S, B = usize>(B::Stored, PhantomData<S>)
where
B: Backend<T>;
pub trait TaggingStrategy<B> {
type Tag;
fn get_tag(data: B) -> Self::Tag;
fn get_ptr_addr(data: B) -> usize;
fn set(addr: usize, tag: Self::Tag) -> B;
}