std/core/plain

std/core/src/plain.trb

Plain, the marker for a value with nothing reference counted inside: a worker may read one through a borrowed pointer into the caller's memory without touching a count (docs/design/CONCURRENCY.md section 6, rule R2).

trait Plain

trait Plain

A type whose values hold nothing reference counted, anywhere inside them. The compiler grants it, from the layout of the type, the way it generates Show; it cannot be implemented, and with Plain is an error.

Granted: Int, Float, Bool, Char, the sized numbers, Array<Float, 16>, and every record, variant and tuple whose fields are all Plain. Refused: String, List, Map and anything that holds one, every shared type, every trait-typed value, every function value, and a type that contains itself.

As a bound it is what lets a function lend its values to code that must not change a count. It is not in the prelude: use Plain from "std/core".

Examples

fn first<Item: Plain>(items: List<Item>): Item {
  items[0]
}