selfstack

selfstack is a procedural macro that produces a stack-like self-referential data structure with a safe interface. This is safe because layers in the stack can only reference layers below them, and lower layers outlive higher layers. This restriction prevents cycles, dangling references, and other unsoundness that would generally be possible with self-reference.

The tests are also run with miri to check generated unsafe code for compliance with stacked borrows.

selfstack vs rental

rental is a similar approach to a similar problem, but it has a few differences.

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.