Skip to content

Commit

Permalink
libs: doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreg committed Feb 10, 2019
1 parent b87363e commit 99ed06e
Show file tree
Hide file tree
Showing 102 changed files with 394 additions and 387 deletions.
4 changes: 2 additions & 2 deletions src/liballoc/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ impl<T> ToOwned for T
/// ```
/// use std::borrow::{Cow, ToOwned};
///
/// struct Items<'a, X: 'a> where [X]: ToOwned<Owned=Vec<X>> {
/// struct Items<'a, X: 'a> where [X]: ToOwned<Owned = Vec<X>> {
/// values: Cow<'a, [X]>,
/// }
///
/// impl<'a, X: Clone + 'a> Items<'a, X> where [X]: ToOwned<Owned=Vec<X>> {
/// impl<'a, X: Clone + 'a> Items<'a, X> where [X]: ToOwned<Owned = Vec<X>> {
/// fn new(v: Cow<'a, [X]>) -> Self {
/// Items { values: v }
/// }
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ struct Hole<'a, T: 'a> {
}

impl<'a, T> Hole<'a, T> {
/// Create a new Hole at index `pos`.
/// Create a new `Hole` at index `pos`.
///
/// Unsafe because pos must be within the data slice.
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2368,7 +2368,7 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {

/// Gets a mutable reference to the value in the entry.
///
/// If you need a reference to the `OccupiedEntry` which may outlive the
/// If you need a reference to the `OccupiedEntry` that may outlive the
/// destruction of the `Entry` value, see [`into_mut`].
///
/// [`into_mut`]: #method.into_mut
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::
}
}

/// Returns whether it is valid to call `.merge()`, i.e., whether there is enough room in
/// Returns `true` if it is valid to call `.merge()`, i.e., whether there is enough room in
/// a node to hold the combination of the nodes to the left and right of this handle along
/// with the key/value pair at this handle.
pub fn can_merge(&self) -> bool {
Expand Down Expand Up @@ -1573,7 +1573,7 @@ unsafe fn move_edges<K, V>(
impl<BorrowType, K, V, HandleType>
Handle<NodeRef<BorrowType, K, V, marker::LeafOrInternal>, HandleType> {

/// Check whether the underlying node is an `Internal` node or a `Leaf` node.
/// Checks whether the underlying node is an `Internal` node or a `Leaf` node.
pub fn force(self) -> ForceResult<
Handle<NodeRef<BorrowType, K, V, marker::Leaf>, HandleType>,
Handle<NodeRef<BorrowType, K, V, marker::Internal>, HandleType>
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ impl<T: Ord> BTreeSet<T> {
Recover::replace(&mut self.map, value)
}

/// Removes a value from the set. Returns `true` if the value was
/// Removes a value from the set. Returns whether the value was
/// present in the set.
///
/// The value may be any borrowed form of the set's value type,
Expand Down Expand Up @@ -988,7 +988,7 @@ impl<'a, T> DoubleEndedIterator for Range<'a, T> {
#[stable(feature = "fused", since = "1.26.0")]
impl<T> FusedIterator for Range<'_, T> {}

/// Compare `x` and `y`, but return `short` if x is None and `long` if y is None
/// Compares `x` and `y`, but return `short` if x is None and `long` if y is None
fn cmp_opt<T: Ord>(x: Option<&T>, y: Option<&T>, short: Ordering, long: Ordering) -> Ordering {
match (x, y) {
(None, _) => short,
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<T> VecDeque<T> {
ptr::write(self.ptr().add(off), value);
}

/// Returns `true` if and only if the buffer is at full capacity.
/// Returns `true` if the buffer is at full capacity.
#[inline]
fn is_full(&self) -> bool {
self.cap() - self.len() == 1
Expand Down Expand Up @@ -560,7 +560,7 @@ impl<T> VecDeque<T> {
/// Does nothing if the capacity is already sufficient.
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore capacity can not be relied upon to be precisely
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve` if future insertions are expected.
///
/// # Errors
Expand Down Expand Up @@ -924,15 +924,15 @@ impl<T> VecDeque<T> {
self.tail == self.head
}

/// Create a draining iterator that removes the specified range in the
/// Creates a draining iterator that removes the specified range in the
/// `VecDeque` and yields the removed items.
///
/// Note 1: The element range is removed even if the iterator is not
/// consumed until the end.
///
/// Note 2: It is unspecified how many elements are removed from the deque,
/// if the `Drain` value is not dropped, but the borrow it holds expires
/// (eg. due to mem::forget).
/// (e.g., due to `mem::forget`).
///
/// # Panics
///
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ macro_rules! vec {
///
/// Additional parameters passed to `format!` replace the `{}`s within the
/// formatting string in the order given unless named or positional parameters
/// are used, see [`std::fmt`][fmt] for more information.
/// are used; see [`std::fmt`][fmt] for more information.
///
/// A common use for `format!` is concatenation and interpolation of strings.
/// The same convention is used with [`print!`] and [`write!`] macros,
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl<T, A: Alloc> RawVec<T, A> {
/// enough to want to do that it's easiest to just have a dedicated method. Slightly
/// more efficient logic can be provided for this than the general case.
///
/// Returns true if the reallocation attempt has succeeded, or false otherwise.
/// Returns `true` if the reallocation attempt has succeeded.
///
/// # Panics
///
Expand Down Expand Up @@ -504,7 +504,7 @@ impl<T, A: Alloc> RawVec<T, A> {
/// the requested space. This is not really unsafe, but the unsafe
/// code *you* write that relies on the behavior of this function may break.
///
/// Returns true if the reallocation attempt has succeeded, or false otherwise.
/// Returns `true` if the reallocation attempt has succeeded.
///
/// # Panics
///
Expand Down
10 changes: 5 additions & 5 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ impl<T: ?Sized> Rc<T> {
this.strong()
}

/// Returns true if there are no other `Rc` or [`Weak`][weak] pointers to
/// Returns `true` if there are no other `Rc` or [`Weak`][weak] pointers to
/// this inner value.
///
/// [weak]: struct.Weak.html
Expand Down Expand Up @@ -561,7 +561,7 @@ impl<T: ?Sized> Rc<T> {

#[inline]
#[stable(feature = "ptr_eq", since = "1.17.0")]
/// Returns true if the two `Rc`s point to the same value (not
/// Returns `true` if the two `Rc`s point to the same value (not
/// just values that compare as equal).
///
/// # Examples
Expand Down Expand Up @@ -1334,8 +1334,8 @@ impl<T: ?Sized> Weak<T> {
})
}

/// Return `None` when the pointer is dangling and there is no allocated `RcBox`,
/// i.e., this `Weak` was created by `Weak::new`
/// Returns `None` when the pointer is dangling and there is no allocated `RcBox`
/// (i.e., when this `Weak` was created by `Weak::new`).
#[inline]
fn inner(&self) -> Option<&RcBox<T>> {
if is_dangling(self.ptr) {
Expand All @@ -1345,7 +1345,7 @@ impl<T: ?Sized> Weak<T> {
}
}

/// Returns true if the two `Weak`s point to the same value (not just values
/// Returns `true` if the two `Weak`s point to the same value (not just values
/// that compare as equal).
///
/// # Notes
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ impl<T> [T] {
///
/// The comparator function must define a total ordering for the elements in the slice. If
/// the ordering is not total, the order of the elements is unspecified. An order is a
/// total order if it is (for all a, b and c):
/// total order if it is (for all `a`, `b` and `c`):
///
/// * total and antisymmetric: exactly one of a < b, a == b or a > b is true; and
/// * transitive, a < b and b < c implies a < c. The same must hold for both == and >.
/// * total and antisymmetric: exactly one of `a < b`, `a == b` or `a > b` is true, and
/// * transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.
///
/// For example, while [`f64`] doesn't implement [`Ord`] because `NaN != NaN`, we can use
/// `partial_cmp` as our sort function when we know the slice doesn't contain a `NaN`.
Expand Down
6 changes: 2 additions & 4 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ impl String {
/// Does nothing if the capacity is already sufficient.
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore capacity can not be relied upon to be precisely
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve` if future insertions are expected.
///
/// # Errors
Expand Down Expand Up @@ -1377,9 +1377,7 @@ impl String {
self.vec.len()
}

/// Returns `true` if this `String` has a length of zero.
///
/// Returns `false` otherwise.
/// Returns `true` if this `String` has a length of zero, and `false` otherwise.
///
/// # Examples
///
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ impl<T: ?Sized> Arc<T> {

#[inline]
#[stable(feature = "ptr_eq", since = "1.17.0")]
/// Returns true if the two `Arc`s point to the same value (not
/// Returns `true` if the two `Arc`s point to the same value (not
/// just values that compare as equal).
///
/// # Examples
Expand Down Expand Up @@ -1191,8 +1191,8 @@ impl<T: ?Sized> Weak<T> {
})
}

/// Return `None` when the pointer is dangling and there is no allocated `ArcInner`,
/// i.e., this `Weak` was created by `Weak::new`
/// Returns `None` when the pointer is dangling and there is no allocated `ArcInner`,
/// (i.e., when this `Weak` was created by `Weak::new`).
#[inline]
fn inner(&self) -> Option<&ArcInner<T>> {
if is_dangling(self.ptr) {
Expand All @@ -1202,7 +1202,7 @@ impl<T: ?Sized> Weak<T> {
}
}

/// Returns true if the two `Weak`s point to the same value (not just values
/// Returns `true` if the two `Weak`s point to the same value (not just values
/// that compare as equal).
///
/// # Notes
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/tests/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::alloc::{Global, Alloc, Layout, System};

/// https://github.com/rust-lang/rust/issues/45955
/// Issue #45955.
#[test]
fn alloc_system_overaligned_request() {
check_overalign_requests(System)
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ impl<T> Vec<T> {
/// Does nothing if the capacity is already sufficient.
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore capacity can not be relied upon to be precisely
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve` if future insertions are expected.
///
/// # Panics
Expand Down Expand Up @@ -525,7 +525,7 @@ impl<T> Vec<T> {
/// Does nothing if the capacity is already sufficient.
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore capacity can not be relied upon to be precisely
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve` if future insertions are expected.
///
/// # Errors
Expand Down Expand Up @@ -2608,7 +2608,7 @@ impl<T> Drain<'_, T> {
/// The range from `self.vec.len` to `self.tail_start` contains elements
/// that have been moved out.
/// Fill that range as much as possible with new elements from the `replace_with` iterator.
/// Return whether we filled the entire range. (`replace_with.next()` didn’t return `None`.)
/// Returns `true` if we filled the entire range. (`replace_with.next()` didn’t return `None`.)
unsafe fn fill<I: Iterator<Item=T>>(&mut self, replace_with: &mut I) -> bool {
let vec = self.vec.as_mut();
let range_start = vec.len;
Expand All @@ -2628,7 +2628,7 @@ impl<T> Drain<'_, T> {
true
}

/// Make room for inserting more elements before the tail.
/// Makes room for inserting more elements before the tail.
unsafe fn move_tail(&mut self, extra_capacity: usize) {
let vec = self.vec.as_mut();
let used_capacity = self.tail_start + self.tail_len;
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
//!
//! This is simply a special - but common - case of the previous: hiding mutability for operations
//! that appear to be immutable. The `clone` method is expected to not change the source value, and
//! is declared to take `&self`, not `&mut self`. Therefore any mutation that happens in the
//! is declared to take `&self`, not `&mut self`. Therefore, any mutation that happens in the
//! `clone` method must use cell types. For example, `Rc<T>` maintains its reference counts within a
//! `Cell<T>`.
//!
Expand Down Expand Up @@ -1145,7 +1145,7 @@ impl<'b, T: ?Sized> Ref<'b, T> {
}
}

/// Make a new `Ref` for a component of the borrowed data.
/// Makes a new `Ref` for a component of the borrowed data.
///
/// The `RefCell` is already immutably borrowed, so this cannot fail.
///
Expand Down Expand Up @@ -1217,7 +1217,7 @@ impl<T: ?Sized + fmt::Display> fmt::Display for Ref<'_, T> {
}

impl<'b, T: ?Sized> RefMut<'b, T> {
/// Make a new `RefMut` for a component of the borrowed data, e.g., an enum
/// Makes a new `RefMut` for a component of the borrowed data, e.g., an enum
/// variant.
///
/// The `RefCell` is already mutably borrowed, so this cannot fail.
Expand Down Expand Up @@ -1416,7 +1416,7 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RefMut<'_, T> {
/// co-exist with it. A `&mut T` must always be unique.
///
/// Note that while mutating or mutably aliasing the contents of an `&UnsafeCell<T>` is
/// okay (provided you enforce the invariants some other way), it is still undefined behavior
/// ok (provided you enforce the invariants some other way), it is still undefined behavior
/// to have multiple `&mut UnsafeCell<T>` aliases.
///
/// # Examples
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/char/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct DecodeUtf16Error {
code: u16,
}

/// Create an iterator over the UTF-16 encoded code points in `iter`,
/// Creates an iterator over the UTF-16 encoded code points in `iter`,
/// returning unpaired surrogates as `Err`s.
///
/// # Examples
Expand Down
Loading

0 comments on commit 99ed06e

Please sign in to comment.