mirror of
https://github.com/microsoft/RustTraining.git
synced 2026-07-08 03:16:12 -04:00
1fa8356e6b
The arena/handle lifetime branding example used covariant PhantomData<&'a ()>, which allowed the compiler to unify lifetimes across different arena instances. The cross-arena usage compiled successfully but panicked at runtime. Fix by: - Making ArenaHandle invariant over 'arena with PhantomData<*mut &'arena ()> so handles from different arenas can't be mixed - Using a with_arena() closure that creates a unique, opaque lifetime per call, preventing the compiler from unifying lifetimes across arena instances - Changing get() to take &ArenaHandle to avoid ownership conflicts Fixes #107