diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-11-26 11:00:36 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-11-26 16:51:02 -0800 |
| commit | e8d743ec1d0a23b0da41f8d79d18b45932a6dd5a (patch) | |
| tree | 13efbac3807230f3c6210cc02d8d79e9bd8129d2 /src/libcore | |
| parent | 60541cdc1ec334b278740fd6d59b9d08929e6d0d (diff) | |
| parent | cd5c8235c5448a7234548c772468c8d2e8f150d9 (diff) | |
| download | rust-e8d743ec1d0a23b0da41f8d79d18b45932a6dd5a.tar.gz rust-e8d743ec1d0a23b0da41f8d79d18b45932a6dd5a.zip | |
rollup merge of #19329: steveklabnik/doc_style_cleanup2
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/clone.rs | 22 | ||||
| -rw-r--r-- | src/libcore/finally.rs | 40 | ||||
| -rw-r--r-- | src/libcore/intrinsics.rs | 62 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 94 | ||||
| -rw-r--r-- | src/libcore/kinds.rs | 19 | ||||
| -rw-r--r-- | src/libcore/ops.rs | 88 |
6 files changed, 154 insertions, 171 deletions
diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index d13daf0964a..9f928f57e9e 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -8,18 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! The `Clone` trait for types that cannot be 'implicitly copied' - -In Rust, some simple types are "implicitly copyable" and when you -assign them or pass them as arguments, the receiver will get a copy, -leaving the original value in place. These types do not require -allocation to copy and do not have finalizers (i.e. they do not -contain owned boxes or implement `Drop`), so the compiler considers -them cheap and safe to copy. For other types copies must be made -explicitly, by convention implementing the `Clone` trait and calling -the `clone` method. - -*/ +//! The `Clone` trait for types that cannot be 'implicitly copied' +//! +//! In Rust, some simple types are "implicitly copyable" and when you +//! assign them or pass them as arguments, the receiver will get a copy, +//! leaving the original value in place. These types do not require +//! allocation to copy and do not have finalizers (i.e. they do not +//! contain owned boxes or implement `Drop`), so the compiler considers +//! them cheap and safe to copy. For other types copies must be made +//! explicitly, by convention implementing the `Clone` trait and calling +//! the `clone` method. #![unstable] diff --git a/src/libcore/finally.rs b/src/libcore/finally.rs index e1e409fbaeb..d2b7591b3ef 100644 --- a/src/libcore/finally.rs +++ b/src/libcore/finally.rs @@ -8,27 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! -The Finally trait provides a method, `finally` on -stack closures that emulates Java-style try/finally blocks. - -Using the `finally` method is sometimes convenient, but the type rules -prohibit any shared, mutable state between the "try" case and the -"finally" case. For advanced cases, the `try_finally` function can -also be used. See that function for more details. - -# Example - -``` -use std::finally::Finally; - -(|| { - // ... -}).finally(|| { - // this code is always run -}) -``` -*/ +//! The Finally trait provides a method, `finally` on +//! stack closures that emulates Java-style try/finally blocks. +//! +//! Using the `finally` method is sometimes convenient, but the type rules +//! prohibit any shared, mutable state between the "try" case and the +//! "finally" case. For advanced cases, the `try_finally` function can +//! also be used. See that function for more details. +//! +//! # Example +//! +//! ``` +//! use std::finally::Finally; +//! +//! (|| { +//! // ... +//! }).finally(|| { +//! // this code is always run +//! }) +//! ``` #![experimental] diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 067ef47a86b..78c74075d48 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -8,38 +8,36 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! rustc compiler intrinsics. - -The corresponding definitions are in librustc/middle/trans/foreign.rs. - -# Volatiles - -The volatile intrinsics provide operations intended to act on I/O -memory, which are guaranteed to not be reordered by the compiler -across other volatile intrinsics. See the LLVM documentation on -[[volatile]]. - -[volatile]: http://llvm.org/docs/LangRef.html#volatile-memory-accesses - -# Atomics - -The atomic intrinsics provide common atomic operations on machine -words, with multiple possible memory orderings. They obey the same -semantics as C++11. See the LLVM documentation on [[atomics]]. - -[atomics]: http://llvm.org/docs/Atomics.html - -A quick refresher on memory ordering: - -* Acquire - a barrier for acquiring a lock. Subsequent reads and writes - take place after the barrier. -* Release - a barrier for releasing a lock. Preceding reads and writes - take place before the barrier. -* Sequentially consistent - sequentially consistent operations are - guaranteed to happen in order. This is the standard mode for working - with atomic types and is equivalent to Java's `volatile`. - -*/ +//! rustc compiler intrinsics. +//! +//! The corresponding definitions are in librustc/middle/trans/foreign.rs. +//! +//! # Volatiles +//! +//! The volatile intrinsics provide operations intended to act on I/O +//! memory, which are guaranteed to not be reordered by the compiler +//! across other volatile intrinsics. See the LLVM documentation on +//! [[volatile]]. +//! +//! [volatile]: http://llvm.org/docs/LangRef.html#volatile-memory-accesses +//! +//! # Atomics +//! +//! The atomic intrinsics provide common atomic operations on machine +//! words, with multiple possible memory orderings. They obey the same +//! semantics as C++11. See the LLVM documentation on [[atomics]]. +//! +//! [atomics]: http://llvm.org/docs/Atomics.html +//! +//! A quick refresher on memory ordering: +//! +//! * Acquire - a barrier for acquiring a lock. Subsequent reads and writes +//! take place after the barrier. +//! * Release - a barrier for releasing a lock. Preceding reads and writes +//! take place before the barrier. +//! * Sequentially consistent - sequentially consistent operations are +//! guaranteed to happen in order. This is the standard mode for working +//! with atomic types and is equivalent to Java's `volatile`. #![experimental] #![allow(missing_docs)] diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 496e7979b72..2d488a4b155 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -8,55 +8,51 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! - -Composable external iterators - -# The `Iterator` trait - -This module defines Rust's core iteration trait. The `Iterator` trait has one -unimplemented method, `next`. All other methods are derived through default -methods to perform operations such as `zip`, `chain`, `enumerate`, and `fold`. - -The goal of this module is to unify iteration across all containers in Rust. -An iterator can be considered as a state machine which is used to track which -element will be yielded next. - -There are various extensions also defined in this module to assist with various -types of iteration, such as the `DoubleEndedIterator` for iterating in reverse, -the `FromIterator` trait for creating a container from an iterator, and much -more. - -## Rust's `for` loop - -The special syntax used by rust's `for` loop is based around the `Iterator` -trait defined in this module. For loops can be viewed as a syntactical expansion -into a `loop`, for example, the `for` loop in this example is essentially -translated to the `loop` below. - -```rust -let values = vec![1i, 2, 3]; - -// "Syntactical sugar" taking advantage of an iterator -for &x in values.iter() { - println!("{}", x); -} - -// Rough translation of the iteration without a `for` iterator. -let mut it = values.iter(); -loop { - match it.next() { - Some(&x) => { - println!("{}", x); - } - None => { break } - } -} -``` - -This `for` loop syntax can be applied to any iterator over any type. - -*/ +//! Composable external iterators +//! +//! # The `Iterator` trait +//! +//! This module defines Rust's core iteration trait. The `Iterator` trait has one +//! unimplemented method, `next`. All other methods are derived through default +//! methods to perform operations such as `zip`, `chain`, `enumerate`, and `fold`. +//! +//! The goal of this module is to unify iteration across all containers in Rust. +//! An iterator can be considered as a state machine which is used to track which +//! element will be yielded next. +//! +//! There are various extensions also defined in this module to assist with various +//! types of iteration, such as the `DoubleEndedIterator` for iterating in reverse, +//! the `FromIterator` trait for creating a container from an iterator, and much +//! more. +//! +//! ## Rust's `for` loop +//! +//! The special syntax used by rust's `for` loop is based around the `Iterator` +//! trait defined in this module. For loops can be viewed as a syntactical expansion +//! into a `loop`, for example, the `for` loop in this example is essentially +//! translated to the `loop` below. +//! +//! ```rust +//! let values = vec![1i, 2, 3]; +//! +//! // "Syntactical sugar" taking advantage of an iterator +//! for &x in values.iter() { +//! println!("{}", x); +//! } +//! +//! // Rough translation of the iteration without a `for` iterator. +//! let mut it = values.iter(); +//! loop { +//! match it.next() { +//! Some(&x) => { +//! println!("{}", x); +//! } +//! None => { break } +//! } +//! } +//! ``` +//! +//! This `for` loop syntax can be applied to any iterator over any type. pub use self::MinMaxResult::*; diff --git a/src/libcore/kinds.rs b/src/libcore/kinds.rs index 6489101f7b9..0c2cb9d5910 100644 --- a/src/libcore/kinds.rs +++ b/src/libcore/kinds.rs @@ -8,17 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! -Primitive traits representing basic 'kinds' of types - -Rust types can be classified in various useful ways according to -intrinsic properties of the type. These classifications, often called -'kinds', are represented as traits. - -They cannot be implemented by user code, but are instead implemented -by the compiler automatically for the types to which they apply. - -*/ +//! Primitive traits representing basic 'kinds' of types +//! +//! Rust types can be classified in various useful ways according to +//! intrinsic properties of the type. These classifications, often called +//! 'kinds', are represented as traits. +//! +//! They cannot be implemented by user code, but are instead implemented +//! by the compiler automatically for the types to which they apply. /// Types able to be transferred across task boundaries. #[lang="send"] diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index b2749ca054a..d85481098e4 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -8,52 +8,48 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! - * - * Overloadable operators - * - * Implementing these traits allows you to get an effect similar to - * overloading operators. - * - * The values for the right hand side of an operator are automatically - * borrowed, so `a + b` is sugar for `a.add(&b)`. - * - * All of these traits are imported by the prelude, so they are available in - * every Rust program. - * - * # Example - * - * This example creates a `Point` struct that implements `Add` and `Sub`, and then - * demonstrates adding and subtracting two `Point`s. - * - * ```rust - * #[deriving(Show)] - * struct Point { - * x: int, - * y: int - * } - * - * impl Add<Point, Point> for Point { - * fn add(&self, other: &Point) -> Point { - * Point {x: self.x + other.x, y: self.y + other.y} - * } - * } - * - * impl Sub<Point, Point> for Point { - * fn sub(&self, other: &Point) -> Point { - * Point {x: self.x - other.x, y: self.y - other.y} - * } - * } - * fn main() { - * println!("{}", Point {x: 1, y: 0} + Point {x: 2, y: 3}); - * println!("{}", Point {x: 1, y: 0} - Point {x: 2, y: 3}); - * } - * ``` - * - * See the documentation for each trait for a minimum implementation that prints - * something to the screen. - * - */ +//! Overloadable operators +//! +//! Implementing these traits allows you to get an effect similar to +//! overloading operators. +//! +//! The values for the right hand side of an operator are automatically +//! borrowed, so `a + b` is sugar for `a.add(&b)`. +//! +//! All of these traits are imported by the prelude, so they are available in +//! every Rust program. +//! +//! # Example +//! +//! This example creates a `Point` struct that implements `Add` and `Sub`, and then +//! demonstrates adding and subtracting two `Point`s. +//! +//! ```rust +//! #[deriving(Show)] +//! struct Point { +//! x: int, +//! y: int +//! } +//! +//! impl Add<Point, Point> for Point { +//! fn add(&self, other: &Point) -> Point { +//! Point {x: self.x + other.x, y: self.y + other.y} +//! } +//! } +//! +//! impl Sub<Point, Point> for Point { +//! fn sub(&self, other: &Point) -> Point { +//! Point {x: self.x - other.x, y: self.y - other.y} +//! } +//! } +//! fn main() { +//! println!("{}", Point {x: 1, y: 0} + Point {x: 2, y: 3}); +//! println!("{}", Point {x: 1, y: 0} - Point {x: 2, y: 3}); +//! } +//! ``` +//! +//! See the documentation for each trait for a minimum implementation that prints +//! something to the screen. use kinds::Sized; |
