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,
Implementations§
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)
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)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
#72631)Reserves capacity in a collection for the given number of additional elements. Read more
Source§#[doc(hidden)] unsafe fn extend_one_unchecked(&mut self, item: A)where
Self: Sized,
#[doc(hidden)] unsafe fn extend_one_unchecked(&mut self, item: A)where
Self: Sized,
🔬This is a nightly-only experimental API. (
extend_one_unchecked
)Extends a collection with one element, without checking there is enough capacity for it. Read more
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 Ord for ()
impl Ord for ()
1.0.0 · Source§impl PartialOrd for ()
impl PartialOrd for ()
Source§#[doc(hidden)] fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool>
🔬This is a nightly-only experimental API. (
partial_ord_chaining_methods
)If
self == other
, returns ControlFlow::Continue(())
.
Otherwise, returns ControlFlow::Break(self < other)
. Read moreSource§#[doc(hidden)] fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool>
🔬This is a nightly-only experimental API. (
partial_ord_chaining_methods
)Same as
__chaining_lt
, but for <=
instead of <
.Source§#[doc(hidden)] fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool>
🔬This is a nightly-only experimental API. (
partial_ord_chaining_methods
)Same as
__chaining_lt
, but for >
instead of <
.Source§#[doc(hidden)] fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool>
🔬This is a nightly-only experimental API. (
partial_ord_chaining_methods
)Same as
__chaining_lt
, but for >=
instead of <
.impl ConstParamTy_ for ()
impl StructuralPartialEq for ()
impl UnsizedConstParamTy 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)] const IS_ZST: bool = _
#[doc(hidden)] const IS_ZST: bool = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)Source§#[doc(hidden)] const LAYOUT: Layout = _
#[doc(hidden)] const LAYOUT: Layout = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)Source§#[doc(hidden)] const MAX_SLICE_LEN: usize = _
#[doc(hidden)] const MAX_SLICE_LEN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)The largest safe length for a
[Self]
. Read more