Skip to content

std/resource

Import with import std/resource.

Interfaces

interface Resource {
    fn close(value: self): Unit
}

Protocol for values that release an acquired host or user-space resource when their enclosing block exits.

A resource name = expr statement binds name for the rest of the current block and calls Resource.close(name) automatically when that block exits. Cleanup runs in reverse acquisition order.