Skip to content
All guides

systems

Ownership and borrows

Every non-copy value has one owner. Scope exit destroys it: files close, memory is freed, no collector pause.

You do not write lifetime annotations. Guarded Flow Analysis tracks moves. If a use is unsafe, the diagnostic names the conflict.

Move by default

list = [1, 2, 3]
use_list(list)

Copy types (int, bool, float, copy types) duplicate. Everything else moves.

Borrow

Most methods insert a borrow. Write ref when the compiler asks, or when you pass a view and still need the value:

send_all(ref socket, payload)
socket.close()

ref mut is exclusive: many shared refs or one ref mut.

give

Reserved. The guest does not lower give x = … (it loads a variable named give). Write socket = connect(...).

Hot loops: keep ref on buffers so you do not move a buffer every iteration. Gate B numbers were taken that way: see performance.