Language / Regions (with)

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 arena: u8[1024];

with arena {
  // `new` allocations use `arena` as backing storage.
}

Example#

struct Point {
  x: int,
  y: int,
}

fn main () -> int {
  const region arena: u8[1024];
  with arena {
    let p: &Point = new Point{ x: 1, y: 2 };
    return p.x + p.y;
  }
}

See also#

Source repository · Edit this page · View Markdown

Quick links

Type to search across the site. Use the up and down arrow keys to choose a result, Enter to open it, and Escape to close.