Skip to content

std::unit

The Unit type: no meaningful value.

Unit is the return type of functions called for their effect (io.print, timer.sleep, Iter.each). There is exactly one Unit value and it carries no information, so there is nothing to construct or inspect.

Unit has no Display impl, so rendering one ("${Unit}", Display.to_string(Unit)) is a compile error. Its Debug form is Unit.

Import with import std::unit.

Types

type Unit

No meaningful value. Functions called for their effect, such as io.print, return it. Unit is Equatable and Hashable: its one value equals itself and always hashes the same, so a tuple, struct or collection holding Unit can be compared, hashed, kept in a Set or used as a Map key.

assert Unit == Unit
assert Equatable.equal(Unit, Unit)
assert Hashable.hash(Unit) == Hashable.hash(Unit)

impl Equatable for Unit

fn equal(_a: Unit, _b: Unit) -> Bool

impl Equatable.equal

impl Hashable for Unit

fn hash(_value: Unit) -> Int

impl Hashable.hash

impl Debug for Unit

fn inspect(value: Unit) -> String

impl Debug.inspect