Skip to content

Commit 51b901e

Browse files
committed
auto merge of #16241 : P1start/rust/doc-fixes, r=alexcrichton
For crates `alloc`–`collections`. This is mostly just updating a few function/method descriptions to use the indicative style. cc #4361; I’ve sort of assumed that the third-person indicative style has been decided on, but I could update this to use the imperative style if that’s preferred, or even update this to remove all function-style-related changes. (I think that standardising on one thing, even if it’s not the ‘best’ option, is still better than having no standard at all.) The indicative style seems to be more common in the Rust standard library at the moment, especially in the newer modules (e.g. `collections::vec`), more popular in the discussion about it, and also more popular amongst other languages (see #4361 (comment)).
2 parents 3f5d0b5 + f2aa88c commit 51b901e

25 files changed

+868
-864
lines changed

src/liballoc/arc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct ArcInner<T> {
7777
}
7878

7979
impl<T: Sync + Send> Arc<T> {
80-
/// Create an atomically reference counted wrapper.
80+
/// Creates an atomically reference counted wrapper.
8181
#[inline]
8282
#[stable]
8383
pub fn new(data: T) -> Arc<T> {
@@ -101,7 +101,7 @@ impl<T: Sync + Send> Arc<T> {
101101
unsafe { &*self._ptr }
102102
}
103103

104-
/// Downgrades a strong pointer to a weak pointer
104+
/// Downgrades a strong pointer to a weak pointer.
105105
///
106106
/// Weak pointers will not keep the data alive. Once all strong references
107107
/// to the underlying data have been dropped, the data itself will be
@@ -224,7 +224,7 @@ impl<T: Sync + Send> Weak<T> {
224224
///
225225
/// This method will fail to upgrade this reference if the strong reference
226226
/// count has already reached 0, but if there are still other active strong
227-
/// references this function will return a new strong reference to the data
227+
/// references this function will return a new strong reference to the data.
228228
pub fn upgrade(&self) -> Option<Arc<T>> {
229229
// We use a CAS loop to increment the strong count instead of a
230230
// fetch_add because once the count hits 0 is must never be above 0.

src/liballoc/boxed.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! A unique pointer type
11+
//! A unique pointer type.
1212
1313
use core::any::{Any, AnyRefExt};
1414
use core::clone::Clone;
@@ -26,12 +26,14 @@ use core::result::{Ok, Err, Result};
2626
///
2727
/// The following two examples are equivalent:
2828
///
29-
/// use std::boxed::HEAP;
29+
/// ```rust
30+
/// use std::boxed::HEAP;
3031
///
31-
/// # struct Bar;
32-
/// # impl Bar { fn new(_a: int) { } }
33-
/// let foo = box(HEAP) Bar::new(2);
34-
/// let foo = box Bar::new(2);
32+
/// # struct Bar;
33+
/// # impl Bar { fn new(_a: int) { } }
34+
/// let foo = box(HEAP) Bar::new(2);
35+
/// let foo = box Bar::new(2);
36+
/// ```
3537
#[lang = "exchange_heap"]
3638
#[experimental = "may be renamed; uncertain about custom allocator design"]
3739
pub static HEAP: () = ();
@@ -47,11 +49,11 @@ impl<T: Default> Default for Box<T> {
4749

4850
#[unstable]
4951
impl<T: Clone> Clone for Box<T> {
50-
/// Return a copy of the owned box.
52+
/// Returns a copy of the owned box.
5153
#[inline]
5254
fn clone(&self) -> Box<T> { box {(**self).clone()} }
5355

54-
/// Perform copy-assignment from `source` by reusing the existing allocation.
56+
/// Performs copy-assignment from `source` by reusing the existing allocation.
5557
#[inline]
5658
fn clone_from(&mut self, source: &Box<T>) {
5759
(**self).clone_from(&(**source));
@@ -86,7 +88,7 @@ impl<T: Ord> Ord for Box<T> {
8688
}
8789
impl<T: Eq> Eq for Box<T> {}
8890

89-
/// Extension methods for an owning `Any` trait object
91+
/// Extension methods for an owning `Any` trait object.
9092
#[unstable = "post-DST and coherence changes, this will not be a trait but \
9193
rather a direct `impl` on `Box<Any>`"]
9294
pub trait BoxAny {

src/liballoc/heap.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#[cfg(not(test))] use core::raw;
1616
#[cfg(not(test))] use util;
1717

18-
/// Return a pointer to `size` bytes of memory.
18+
/// Returns a pointer to `size` bytes of memory.
1919
///
2020
/// Behavior is undefined if the requested size is 0 or the alignment is not a
2121
/// power of 2. The alignment must be no larger than the largest supported page
@@ -25,7 +25,7 @@ pub unsafe fn allocate(size: uint, align: uint) -> *mut u8 {
2525
imp::allocate(size, align)
2626
}
2727

28-
/// Extend or shrink the allocation referenced by `ptr` to `size` bytes of
28+
/// Extends or shrinks the allocation referenced by `ptr` to `size` bytes of
2929
/// memory.
3030
///
3131
/// Behavior is undefined if the requested size is 0 or the alignment is not a
@@ -41,10 +41,10 @@ pub unsafe fn reallocate(ptr: *mut u8, size: uint, align: uint,
4141
imp::reallocate(ptr, size, align, old_size)
4242
}
4343

44-
/// Extend or shrink the allocation referenced by `ptr` to `size` bytes of
44+
/// Extends or shrinks the allocation referenced by `ptr` to `size` bytes of
4545
/// memory in-place.
4646
///
47-
/// Return true if successful, otherwise false if the allocation was not
47+
/// Returns true if successful, otherwise false if the allocation was not
4848
/// altered.
4949
///
5050
/// Behavior is undefined if the requested size is 0 or the alignment is not a
@@ -60,7 +60,7 @@ pub unsafe fn reallocate_inplace(ptr: *mut u8, size: uint, align: uint,
6060
imp::reallocate_inplace(ptr, size, align, old_size)
6161
}
6262

63-
/// Deallocate the memory referenced by `ptr`.
63+
/// Deallocates the memory referenced by `ptr`.
6464
///
6565
/// The `ptr` parameter must not be null.
6666
///
@@ -72,14 +72,14 @@ pub unsafe fn deallocate(ptr: *mut u8, size: uint, align: uint) {
7272
imp::deallocate(ptr, size, align)
7373
}
7474

75-
/// Return the usable size of an allocation created with the specified the
75+
/// Returns the usable size of an allocation created with the specified the
7676
/// `size` and `align`.
7777
#[inline]
7878
pub fn usable_size(size: uint, align: uint) -> uint {
7979
imp::usable_size(size, align)
8080
}
8181

82-
/// Print implementation-defined allocator statistics.
82+
/// Prints implementation-defined allocator statistics.
8383
///
8484
/// These statistics may be inconsistent if other threads use the allocator
8585
/// during the call.
@@ -88,7 +88,7 @@ pub fn stats_print() {
8888
imp::stats_print();
8989
}
9090

91-
// The compiler never calls `exchange_free` on ~ZeroSizeType, so zero-size
91+
// The compiler never calls `exchange_free` on Box<ZeroSizeType>, so zero-size
9292
// allocations can point to this `static`. It would be incorrect to use a null
9393
// pointer, due to enums assuming types like unique pointers are never null.
9494
pub static mut EMPTY: uint = 12345;

src/liballoc/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Rust's core allocation library
11+
//! # The Rust core allocation library
1212
//!
1313
//! This is the lowest level library through which allocation in Rust can be
1414
//! performed where the allocation is assumed to succeed. This library will
@@ -23,22 +23,22 @@
2323
//!
2424
//! ## Boxed values
2525
//!
26-
//! The [`Box`](boxed/index.html) type is the core owned pointer type in rust.
26+
//! The [`Box`](boxed/index.html) type is the core owned pointer type in Rust.
2727
//! There can only be one owner of a `Box`, and the owner can decide to mutate
2828
//! the contents, which live on the heap.
2929
//!
3030
//! This type can be sent among tasks efficiently as the size of a `Box` value
31-
//! is just a pointer. Tree-like data structures are often built on owned
32-
//! pointers because each node often has only one owner, the parent.
31+
//! is the same as that of a pointer. Tree-like data structures are often built
32+
//! with boxes because each node often has only one owner, the parent.
3333
//!
3434
//! ## Reference counted pointers
3535
//!
3636
//! The [`Rc`](rc/index.html) type is a non-threadsafe reference-counted pointer
3737
//! type intended for sharing memory within a task. An `Rc` pointer wraps a
3838
//! type, `T`, and only allows access to `&T`, a shared reference.
3939
//!
40-
//! This type is useful when inherited mutability is too constraining for an
41-
//! application (such as using `Box`), and is often paired with the `Cell` or
40+
//! This type is useful when inherited mutability (such as using `Box`) is too
41+
//! constraining for an application, and is often paired with the `Cell` or
4242
//! `RefCell` types in order to allow mutation.
4343
//!
4444
//! ## Atomically reference counted pointers

src/liballoc/libc_heap.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -14,7 +14,7 @@
1414
use libc::{c_void, size_t, free, malloc, realloc};
1515
use core::ptr::{RawPtr, mut_null};
1616

17-
/// A wrapper around libc::malloc, aborting on out-of-memory
17+
/// A wrapper around libc::malloc, aborting on out-of-memory.
1818
#[inline]
1919
pub unsafe fn malloc_raw(size: uint) -> *mut u8 {
2020
// `malloc(0)` may allocate, but it may also return a null pointer
@@ -30,7 +30,7 @@ pub unsafe fn malloc_raw(size: uint) -> *mut u8 {
3030
}
3131
}
3232

33-
/// A wrapper around libc::realloc, aborting on out-of-memory
33+
/// A wrapper around libc::realloc, aborting on out-of-memory.
3434
#[inline]
3535
pub unsafe fn realloc_raw(ptr: *mut u8, size: uint) -> *mut u8 {
3636
// `realloc(ptr, 0)` may allocate, but it may also return a null pointer

0 commit comments

Comments
 (0)