core: add a primitive page for ().

This commit is contained in:
Huon Wilson 2014-07-02 10:21:15 +10:00
parent f89cc11827
commit 7c92735f08
4 changed files with 53 additions and 0 deletions

View File

@ -122,6 +122,10 @@
pub mod slice;
pub mod str;
pub mod tuple;
// FIXME #15320: primitive documentation needs top-level modules, this
// should be `core::tuple::unit`.
#[path = "tuple/unit.rs"]
pub mod unit;
pub mod fmt;
#[doc(hidden)]

View File

@ -61,6 +61,8 @@
#![doc(primitive = "tuple")]
pub use unit;
use clone::Clone;
use cmp::*;
use default::Default;

44
src/libcore/tuple/unit.rs Normal file
View File

@ -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,
//!
//! ```rust
//! fn returns_i64() -> i64 {
//! 1i64
//! }
//! fn returns_unit() {
//! 1i64;
//! }
//!
//! let is_i64 = {
//! returns_i64()
//! };
//! let is_unit = {
//! returns_i64();
//! };
//! ```

View File

@ -160,6 +160,9 @@
pub use core::raw;
pub use core::simd;
pub use core::tuple;
// FIXME #15320: primitive documentation needs top-level modules, this
// should be `std::tuple::unit`.
pub use core::unit;
#[cfg(not(test))] pub use core::ty;
pub use core::result;
pub use core::option;