In the section "Lifetime Branding" of Chapter 04 (PhantomData types that carry no data):
https://microsoft.github.io/RustTraining/rust-patterns-book/ch04-phantomdata-types-that-carry-no-data.html#lifetime-branding
the branding seems to have no effect. Using the wrong handle with an arena is supposed to be a compile time error, but if I uncomment that code:
// Can't use handle1 with a different arena — lifetimes won't match
// let arena2 = Arena::new();
// arena2.get(handle1); // ❌ Lifetime mismatch
I get no compile time error, but at runtime it panics because I used the wrong handle with arena2.
thread 'main' (14) panicked at src/main.rs:30:13:
index out of bounds: the len is 0 but the index is 0
Rust playground example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=4486796f55558436f8d3c482ded7bdd1
In the section "Lifetime Branding" of Chapter 04 (PhantomData types that carry no data):
https://microsoft.github.io/RustTraining/rust-patterns-book/ch04-phantomdata-types-that-carry-no-data.html#lifetime-branding
the branding seems to have no effect. Using the wrong handle with an arena is supposed to be a compile time error, but if I uncomment that code:
I get no compile time error, but at runtime it panics because I used the wrong handle with
arena2.Rust playground example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=4486796f55558436f8d3c482ded7bdd1