mirror of
https://github.com/Noratrieb/stuff.git
synced 2026-01-14 16:35:08 +01:00
add pointer tag
This commit is contained in:
parent
3209133840
commit
c54e5531aa
3 changed files with 18 additions and 2 deletions
|
|
@ -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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
17
src/tag.rs
Normal 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;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue