nearest
Self-relative pointers and region-based allocation for Rust.
Store entire data graphs in a single contiguous byte buffer where all internal
pointers are 4-byte i32 offsets relative to their own address — cloning a
region is a plain memcpy with no fixup.
Example
use ;
// Build
let mut region = new;
assert_eq!;
// Read (Region<T>: Deref<Target = T>)
assert_eq!;
assert_eq!;
// Mutate via branded session
region.session;
assert_eq!;
// Clone is memcpy
let cloned = region.clone;
assert_eq!;
Highlights
- Zero-cost clone —
Region::cloneis amemcpy; self-relative offsets need no fixup - Compile-time safety — ghost-cell branded sessions prevent
Refescape or cross-session use - Declarative construction —
#[derive(Flat)]generatesmake()builders for tree-shaped data - Compaction —
Region::trimreclaims dead bytes left by append-only mutations - Miri-validated — all unsafe code tested under Miri with permissive provenance
Getting started
Requires nightly Rust due to #![feature(offset_of_enum)].
[]
= "0.1"
See the API documentation for comprehensive guides and examples.
Minimum Supported Rust Version
Nightly Rust (rust-version = "1.93.0"), pinned to nightly-2026-02-10.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
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.