Primitive Type unit Copy item path 1.0.0 Expand description The () type, also called “unit”.
The () type has exactly one value (), and is used when there
is no other meaningful value that could be returned. () is most
commonly seen implicitly: functions without a -> ... implicitly
have return type (), that is, these are equivalent:
fn long() -> () {}
fn short() {}
The semicolon ; can be used to discard the result of an
expression at the end of a block, making the expression (and thus
the block) evaluate to (). For example,
fn returns_i64() -> i64 {
1i64
}
fn returns_unit() {
1i64 ;
}
let is_i64 = {
returns_i64()
};
let is_unit = {
returns_i64();
};Returns the default value of ()
Compares and returns the maximum of two values.
Read more Compares and returns the minimum of two values.
Read more Restrict a value to a certain interval.
Read more Tests for self and other values to be equal, and is used by ==.
Tests for !=. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
This method returns an ordering between
self and
other values if one exists.
Read more Tests less than (for
self and
other) and is used by the
< operator.
Read more Tests less than or equal to (for
self and
other) and is used by the
<= operator.
Read more Tests greater than (for
self and
other) and is used by the
>
operator.
Read more Tests greater than or equal to (for
self and
other) and is used by
the
>= operator.
Read more Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.