Regions (with)
Regions provide a fixed-size, statically allocated backing store that can be
used as an allocation context for new.
Full reference: regions.
Notes#
- Supported forms + Limitations: regions
Syntax#
const region region_buf: u8[1024];
with region_buf {
// `new` allocations use `region_buf` as backing storage.
}
Example#
struct Point {
x: int,
y: int,
}
fn main () -> int {
const region region_buf: u8[1024];
with region_buf {
let p: &Point = new Point{ x: 1, y: 2 };
return p.x + p.y;
}
}
See also#
- Full reference: regions
- Memory model and
new: memory model --noheapandstd::runtime::mem: runtime
Source repository · Edit this page · View Markdown