Memory ownership and access vocabulary built from brands and linear values.
Re-exports
sizeof | Re-export of a builtin. |
alloca | Re-export of a builtin. |
enum_variant | Re-export of a builtin. |
Types
Ref | A description of the place of a T in domain 'k, read or written by presenting that domain's capability. |
Region! | The right to access one block holding a T, under brand 'r. |
RegionResume! | The receipt Region!::share keeps back, and the ONLY route from an Exclusive!['r] back to a Region![T,'r]: the base pointer plus the brand, and nothing else. |
Link! | The tie between a part of a split region and the region it came from. |
Restore! | The receipt Region!::split keeps back: the base pointer and the parent's own Exclusive!['r], held while the parts are out. |
AlignProbe | A u8 followed by a T, whose size gives the alignment of T. |
Functions
lend | Lends *p to f in place: f gets the value through &, and the value it leaves there is *p afterwards. |
lend_in | lend, with a context cx lent to f beside *p: the other values the closure works on, which it could not capture (a closure that may go uncalled captures only Copy values). |
alignof | The alignment of T in bytes, as C lays it out: a power of two, 1 for a zero-size type. |
swap | Exchanges the values of two places. |
replace | Puts val in dst and returns what was there: how a linear value in a place is swapped out, where dst = val; would drop the previous one (let old = mem::replace(&self.slot, fresh);). |
make_split_part | A region over field under a fresh brand, and that brand: Region!::split's per-field step. |
Function declarations
fn lendsource
forall T, Ret where Sized[T].
unsafe fn lend(p: *T, f: closure(&_: T) -> Ret) -> Ret { ... }
Lends *p to f in place: f gets the value through &, and the value it leaves there is *p afterwards. unsafe &*p lends the target itself, so the call passes p. Caller: p points at a live T that nothing else reads or writes while f runs.
fn lend_insource
forall T, C, Ret where Sized[T].
unsafe fn lend_in(p: *T, &cx: C, f: closure(&_: T, &_: C) -> Ret) -> Ret { ... }
lend, with a context cx lent to f beside *p: the other values the closure works on, which it could not capture (a closure that may go uncalled captures only Copy values). Bundle several into one struct. Caller: as for lend.
fn alignofsource
forall T.
fn alignof() -> usize { ... }
The alignment of T in bytes, as C lays it out: a power of two, 1 for a zero-size type.
fn swapsource
forall T.
fn swap(&a: T, &b: T) { ... }
Exchanges the values of two places.
fn replacesource
forall T.
fn replace(&dst: T, val: T) -> T { ... }
Puts val in dst and returns what was there: how a linear value in a place is swapped out, where dst = val; would drop the previous one (let old = mem::replace(&self.slot, fresh);).
fn make_split_partsource
forall Field.
unsafe fn make_split_part(field: *Field) -> exists 'f. (Region![Field, 'f], Brand['f]) { ... }
A region over field under a fresh brand, and that brand: Region!::split's per-field step. A separate function, not inlined in split's foreach body, because the exists 'f. (...) a foreach component produces must be a SEALED RETURN: Exclusive!::fresh mints and seals one brand per call.
It mints the child brand and hands back only that, never a Link!. A helper taking the PARENT brand as a parameter and returning a Link! would forge authority: a Brand['r] is Copy and readable off any live Ref naming 'r, so it proves nothing about holding 'r. split instead reads the parent brand from the region's own Exclusive!['r] and builds each Link! itself.
unsafe fn because it takes a raw pointer that is trusted, unvalidated, and immediately wrapped in a Region!, and any module can call it, not only split. Caller: field addresses initialized storage of Field that no other live capability covers, as for Region!::from_raw. split meets it with field pointers computed by foreach over a region it gave up exclusively. The part returned carries only its own fresh brand; since Link! is built by split alone, a part over unrelated storage can never be merged into a parent.