Primitive Type unit
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:
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,
Trait Implementations§
1.28.0 · Source§impl Extend<()> for ()
impl Extend<()> for ()
Source§fn extend<T: IntoIterator<Item = ()>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = ()>>(&mut self, iter: T)
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B).
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, _item: ())
fn extend_one(&mut self, _item: ())
🔬This is a nightly-only experimental API. (
extend_one #72631)This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B).
Extends a collection with exactly one element.
1.23.0 · Source§impl FromIterator<()> for ()
Collapses all unit items from an iterator into one.
impl FromIterator<()> for ()
Collapses all unit items from an iterator into one.
This is more useful when combined with higher-level abstractions, like
collecting to a Result<(), E> where you only care about errors:
1.0.0 · Source§impl Hash for ()
impl Hash for ()
1.0.0 (const: unstable) · Source§impl Ord for ()
impl Ord for ()
Source§fn cmp(&self, _other: &()) -> Ordering
fn cmp(&self, _other: &()) -> Ordering
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B).
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B).
Compares and returns the maximum of two values. Read more
1.0.0 (const: unstable) · Source§impl PartialEq for ()
impl PartialEq for ()
1.0.0 (const: unstable) · Source§impl PartialOrd for ()
impl PartialOrd for ()
Source§fn partial_cmp(&self, _: &()) -> Option<Ordering>
fn partial_cmp(&self, _: &()) -> Option<Ordering>
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B).
1.0.0 · Source§fn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B).
1.0.0 · Source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B).
impl ConstParamTy_ for ()
impl Eq for ()
impl StructuralPartialEq for ()
Auto Trait Implementations§
impl Freeze for ()
impl RefUnwindSafe for ()
impl Send for ()
impl Sync for ()
impl Unpin for ()
impl UnsafeUnpin for ()
impl UnwindSafe for ()
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
This item is validated for IEC 61508 (SIL 2) and ISO 26262 (ASIL B).
Mutably borrows from an owned value. Read more