ilusm.dev

msafe

Memory safety, ownership, borrowing, lifetimes.

Load with: use msafe

Quick example

use msafe

result = own("value")
prn(result)

Functions

Ownership types

own(v)

Performs the operation. Takes v.

Borrow checking

bor(o, m)

Performs the operation. Takes o, m.

borre(b)

Performs the operation. Takes b.

Reference counting (shared ownership)

rc(v)

Performs the operation. Takes v.

rcc(r)

Performs the operation. Takes r.

rcd(r)

Performs the operation. Takes r.

Arc (atomic reference counting for thread safety)

arc(v)

Performs the operation. Takes v.

Box (heap allocation)

msbox(v)

Performs the operation. Takes v.

boxg(b)

Performs the operation. Takes b.

boxs(b, v)

Performs the operation. Takes b, v.

boxd(b)

Performs the operation. Takes b.

Null pointer optimization

opt(v)

Performs the operation. Takes v.

optn()

Performs the operation.

optu(o)

Performs the operation. Takes o.

opto(o, d)

Converts to another format. Takes o, d.

optm(o, fn)

Performs the operation. Takes o, fn.

Result type for error handling

ok(v)

Performs the operation. Takes v.

err(e)

Performs the operation. Takes e.

resu(r)

Performs the operation. Takes r.

reso(r, d)

Performs the operation. Takes r, d.

resm(r, fn)

Performs the operation. Takes r, fn.

Lifetime tracking

lifn(n)

Finalises. Takes n.

Move semantics

mov(v)

Performs the operation. Takes v.

movt(m)

Performs the operation. Takes m.

Cell (interior mutability)

cell(v)

Performs the operation. Takes v.

RefCell (runtime borrow checking)

rcell(v)

Performs the operation. Takes v.

Drop trait simulation

drop(o, fn)

Opens a connection or resource. Takes o, fn.

dropd(o)

Performs the operation. Takes o.

Memory leak detection

leak()

Performs the operation.

Scoped guards

guard(r, fn)

Reads data. Takes r, fn.

guard(g)

Reads data. Takes g.

RAII pattern

raiig(a, r)

Performs the operation. Takes a, r.

Pin (guarantee memory location doesn't change)

pinnn(v)

Performs the operation. Takes v.

Notes

  • Memory safety helpers - bounds checking, use-after-free detection.