This crate provides a procedural macro for deriving the StrongHandle
interface on simple wrappers around the Handle
type when working with the StrongRegistry
container in the zone-alloc
crate.
toml
[dependencies]
zone-alloc = "0.1"
zone-alloc-strong-handle-derive = "0.1"
This crate defines one procedural macro:
StrongHandle
- Automatically derives the StrongHandle
interface for simple wrappers around the Handle
type.Arena<T>
]``` use zonealloc::{ Handle, StrongRegistry, }; use zoneallocstronghandle_derive::StrongHandle;
struct NodeHandle(Handle);
struct Node
impl
fn main() {
let registry = StrongRegistry::
let node = registry.get(handle).unwrap();
assert_eq!(node.value, "third");
let node = registry.get(node.parent.unwrap()).unwrap();
assert_eq!(node.value, "second");
let node = registry.get(node.parent.unwrap()).unwrap();
assert_eq!(node.value, "first");
let node = registry.get(node.parent.unwrap()).unwrap();
assert_eq!(node.value, "third");
} ```