-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add primitive doc for () #15321
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add primitive doc for () #15321
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,8 @@ | |
|
||
#![doc(primitive = "tuple")] | ||
|
||
pub use unit; | ||
|
||
use clone::Clone; | ||
use cmp::*; | ||
use default::Default; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![doc(primitive = "unit")] | ||
|
||
//! The `()` type, sometimes called "unit" or "nil". | ||
//! | ||
//! 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: | ||
//! | ||
//! ```rust | ||
//! 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've been using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, don't know. (It's mainly just a habit I have from mathematics, where even an "broken out" equation is normally written to be a natural part of the sentence it's in
This may not be the style we want for Rust's docs.) |
||
//! | ||
//! ```rust | ||
//! fn returns_i64() -> i64 { | ||
//! 1i64 | ||
//! } | ||
//! fn returns_unit() { | ||
//! 1i64; | ||
//! } | ||
//! | ||
//! let is_i64 = { | ||
//! returns_i64() | ||
//! }; | ||
//! let is_unit = { | ||
//! returns_i64(); | ||
//! }; | ||
//! ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe mention
;
too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a paragraph below; what do you think?