Unit Type

The unit type, written (), has exactly one value, also written ().

Functions without an explicit return type annotation implicitly return ().

Expressions that produce side effects but no meaningful value have type ().

The unit type is a zero-sized type. See Zero-Sized Types for the general definition.

fn do_nothing() {
    // Implicitly returns ()
}

fn explicit_unit() -> () {
    // Explicitly returns ()
}

fn main() -> i32 {
    do_nothing();
    explicit_unit();
    0
}