Skip to content

Commit 7267bce

Browse files
authored
Rollup merge of rust-lang#59082 - alexreg:cosmetic-2-doc-comments, r=Centril
A few improvements to comments in user-facing crates Not too many this time, and all concern comments (almost all doc comments) in user-facing crates (libstd, libcore, liballoc). r? @steveklabnik
2 parents 8a55a86 + d4b2071 commit 7267bce

File tree

15 files changed

+39
-36
lines changed

15 files changed

+39
-36
lines changed

src/libcore/iter/adapters/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ impl<I: Iterator> Peekable<I> {
11981198
}
11991199
}
12001200

1201-
/// An iterator that rejects elements while `predicate` is true.
1201+
/// An iterator that rejects elements while `predicate` returns `true`.
12021202
///
12031203
/// This `struct` is created by the [`skip_while`] method on [`Iterator`]. See its
12041204
/// documentation for more.
@@ -1286,7 +1286,7 @@ impl<I: Iterator, P> Iterator for SkipWhile<I, P>
12861286
impl<I, P> FusedIterator for SkipWhile<I, P>
12871287
where I: FusedIterator, P: FnMut(&I::Item) -> bool {}
12881288

1289-
/// An iterator that only accepts elements while `predicate` is true.
1289+
/// An iterator that only accepts elements while `predicate` returns `true`.
12901290
///
12911291
/// This `struct` is created by the [`take_while`] method on [`Iterator`]. See its
12921292
/// documentation for more.

src/libcore/mem.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1111,11 +1111,12 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
11111111
/// ```
11121112
///
11131113
/// The compiler then knows to not make any incorrect assumptions or optimizations on this code.
1114+
//
11141115
// FIXME before stabilizing, explain how to initialize a struct field-by-field.
11151116
#[allow(missing_debug_implementations)]
11161117
#[unstable(feature = "maybe_uninit", issue = "53491")]
11171118
#[derive(Copy)]
1118-
// NOTE after stabilizing `MaybeUninit` proceed to deprecate `mem::uninitialized`.
1119+
// NOTE: after stabilizing `MaybeUninit`, proceed to deprecate `mem::uninitialized`.
11191120
pub union MaybeUninit<T> {
11201121
uninit: (),
11211122
value: ManuallyDrop<T>,
@@ -1125,13 +1126,13 @@ pub union MaybeUninit<T> {
11251126
impl<T: Copy> Clone for MaybeUninit<T> {
11261127
#[inline(always)]
11271128
fn clone(&self) -> Self {
1128-
// Not calling T::clone(), we cannot know if we are initialized enough for that.
1129+
// Not calling `T::clone()`, we cannot know if we are initialized enough for that.
11291130
*self
11301131
}
11311132
}
11321133

11331134
impl<T> MaybeUninit<T> {
1134-
/// Create a new `MaybeUninit<T>` initialized with the given value.
1135+
/// Creates a new `MaybeUninit<T>` initialized with the given value.
11351136
///
11361137
/// Note that dropping a `MaybeUninit<T>` will never call `T`'s drop code.
11371138
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
@@ -1239,6 +1240,7 @@ impl<T> MaybeUninit<T> {
12391240
/// let x_vec = unsafe { &*x.as_ptr() };
12401241
/// // We have created a reference to an uninitialized vector! This is undefined behavior.
12411242
/// ```
1243+
///
12421244
/// (Notice that the rules around references to uninitialized data are not finalized yet, but
12431245
/// until they are, it is advisable to avoid them.)
12441246
#[unstable(feature = "maybe_uninit", issue = "53491")]
@@ -1277,6 +1279,7 @@ impl<T> MaybeUninit<T> {
12771279
/// let x_vec = unsafe { &mut *x.as_mut_ptr() };
12781280
/// // We have created a reference to an uninitialized vector! This is undefined behavior.
12791281
/// ```
1282+
///
12801283
/// (Notice that the rules around references to uninitialized data are not finalized yet, but
12811284
/// until they are, it is advisable to avoid them.)
12821285
#[unstable(feature = "maybe_uninit", issue = "53491")]

src/libcore/num/dec2flt/algorithm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ pub fn algorithm_m<T: RawFloat>(f: &Big, e: i16) -> T {
326326
round_by_remainder(v, rem, q, z)
327327
}
328328

329-
/// Skip over most Algorithm M iterations by checking the bit length.
329+
/// Skips over most Algorithm M iterations by checking the bit length.
330330
fn quick_start<T: RawFloat>(u: &mut Big, v: &mut Big, k: &mut i16) {
331331
// The bit length is an estimate of the base two logarithm, and log(u / v) = log(u) - log(v).
332332
// The estimate is off by at most 1, but always an under-estimate, so the error on log(u)

src/libcore/num/dec2flt/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ fn simplify(decimal: &mut Decimal) {
304304
}
305305
}
306306

307-
/// Quick and dirty upper bound on the size (log10) of the largest value that Algorithm R and
308-
/// Algorithm M will compute while working on the given decimal.
307+
/// Returns a quick-an-dirty upper bound on the size (log10) of the largest value that Algorithm R
308+
/// and Algorithm M will compute while working on the given decimal.
309309
fn bound_intermediate_digits(decimal: &Decimal, e: i64) -> u64 {
310310
// We don't need to worry too much about overflow here thanks to trivial_cases() and the
311311
// parser, which filter out the most extreme inputs for us.
@@ -324,7 +324,7 @@ fn bound_intermediate_digits(decimal: &Decimal, e: i64) -> u64 {
324324
}
325325
}
326326

327-
/// Detect obvious overflows and underflows without even looking at the decimal digits.
327+
/// Detects obvious overflows and underflows without even looking at the decimal digits.
328328
fn trivial_cases<T: RawFloat>(decimal: &Decimal) -> Option<T> {
329329
// There were zeros but they were stripped by simplify()
330330
if decimal.integral.is_empty() && decimal.fractional.is_empty() {

src/libcore/num/dec2flt/parse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn parse_decimal(s: &str) -> ParseResult {
7878
}
7979
}
8080

81-
/// Carve off decimal digits up to the first non-digit character.
81+
/// Carves off decimal digits up to the first non-digit character.
8282
fn eat_digits(s: &[u8]) -> (&[u8], &[u8]) {
8383
let mut i = 0;
8484
while i < s.len() && b'0' <= s[i] && s[i] <= b'9' {

src/libcore/num/flt2dec/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use num::dec2flt::rawfp::RawFloat;
1010
///
1111
/// - Any number from `(mant - minus) * 2^exp` to `(mant + plus) * 2^exp` will
1212
/// round to the original value. The range is inclusive only when
13-
/// `inclusive` is true.
13+
/// `inclusive` is `true`.
1414
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
1515
pub struct Decoded {
1616
/// The scaled mantissa.

src/libcore/num/flt2dec/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,15 @@ fn digits_to_dec_str<'a>(buf: &'a [u8], exp: i16, frac_digits: usize,
315315
}
316316
}
317317

318-
/// Formats given decimal digits `0.<...buf...> * 10^exp` into the exponential form
319-
/// with at least given number of significant digits. When `upper` is true,
318+
/// Formats the given decimal digits `0.<...buf...> * 10^exp` into the exponential
319+
/// form with at least the given number of significant digits. When `upper` is `true`,
320320
/// the exponent will be prefixed by `E`; otherwise that's `e`. The result is
321321
/// stored to the supplied parts array and a slice of written parts is returned.
322322
///
323323
/// `min_digits` can be less than the number of actual significant digits in `buf`;
324324
/// it will be ignored and full digits will be printed. It is only used to print
325-
/// additional zeroes after rendered digits. Thus `min_digits` of 0 means that
326-
/// it will only print given digits and nothing else.
325+
/// additional zeroes after rendered digits. Thus, `min_digits == 0` means that
326+
/// it will only print the given digits and nothing else.
327327
fn digits_to_exp_str<'a>(buf: &'a [u8], exp: i16, min_ndigits: usize, upper: bool,
328328
parts: &'a mut [Part<'a>]) -> &'a [Part<'a>] {
329329
assert!(!buf.is_empty());
@@ -384,7 +384,7 @@ fn determine_sign(sign: Sign, decoded: &FullDecoded, negative: bool) -> &'static
384384
}
385385
}
386386

387-
/// Formats given floating point number into the decimal form with at least
387+
/// Formats the given floating point number into the decimal form with at least
388388
/// given number of fractional digits. The result is stored to the supplied parts
389389
/// array while utilizing given byte buffer as a scratch. `upper` is currently
390390
/// unused but left for the future decision to change the case of non-finite values,
@@ -438,7 +438,7 @@ pub fn to_shortest_str<'a, T, F>(mut format_shortest: F, v: T,
438438
}
439439
}
440440

441-
/// Formats given floating point number into the decimal form or
441+
/// Formats the given floating point number into the decimal form or
442442
/// the exponential form, depending on the resulting exponent. The result is
443443
/// stored to the supplied parts array while utilizing given byte buffer
444444
/// as a scratch. `upper` is used to determine the case of non-finite values
@@ -497,7 +497,7 @@ pub fn to_shortest_exp_str<'a, T, F>(mut format_shortest: F, v: T,
497497
}
498498
}
499499

500-
/// Returns rather crude approximation (upper bound) for the maximum buffer size
500+
/// Returns a rather crude approximation (upper bound) for the maximum buffer size
501501
/// calculated from the given decoded exponent.
502502
///
503503
/// The exact limit is:

src/libcore/pin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Types which pin data to its location in memory
1+
//! Types that pin data to its location in memory.
22
//!
33
//! It is sometimes useful to have objects that are guaranteed to not move,
44
//! in the sense that their placement in memory does not change, and can thus be relied upon.

src/libcore/str/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2968,7 +2968,7 @@ impl str {
29682968
///
29692969
/// The returned iterator will be a [`DoubleEndedIterator`] if the pattern
29702970
/// allows a reverse search and forward/reverse search yields the same
2971-
/// elements. This is true for, eg, [`char`] but not for `&str`.
2971+
/// elements. This is true for, e.g., [`char`], but not for `&str`.
29722972
///
29732973
/// [`DoubleEndedIterator`]: iter/trait.DoubleEndedIterator.html
29742974
///
@@ -3143,7 +3143,7 @@ impl str {
31433143
///
31443144
/// The returned iterator will be a [`DoubleEndedIterator`] if the pattern
31453145
/// allows a reverse search and forward/reverse search yields the same
3146-
/// elements. This is true for, eg, [`char`] but not for `&str`.
3146+
/// elements. This is true for, e.g., [`char`], but not for `&str`.
31473147
///
31483148
/// [`DoubleEndedIterator`]: iter/trait.DoubleEndedIterator.html
31493149
///
@@ -3326,7 +3326,7 @@ impl str {
33263326
///
33273327
/// The returned iterator will be a [`DoubleEndedIterator`] if the pattern
33283328
/// allows a reverse search and forward/reverse search yields the same
3329-
/// elements. This is true for, eg, [`char`] but not for `&str`.
3329+
/// elements. This is true for, e.g., [`char`], but not for `&str`.
33303330
///
33313331
/// [`DoubleEndedIterator`]: iter/trait.DoubleEndedIterator.html
33323332
///
@@ -3402,7 +3402,7 @@ impl str {
34023402
///
34033403
/// The returned iterator will be a [`DoubleEndedIterator`] if the pattern
34043404
/// allows a reverse search and forward/reverse search yields the same
3405-
/// elements. This is true for, eg, [`char`] but not for `&str`.
3405+
/// elements. This is true for, e.g., [`char`], but not for `&str`.
34063406
///
34073407
/// [`DoubleEndedIterator`]: iter/trait.DoubleEndedIterator.html
34083408
///

src/libcore/task/wake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl Waker {
108108
unsafe { (self.waker.vtable.wake)(self.waker.data) }
109109
}
110110

111-
/// Returns whether or not this `Waker` and other `Waker` have awaken the same task.
111+
/// Returns `true` if this `Waker` and another `Waker` have awoken the same task.
112112
///
113113
/// This function works on a best-effort basis, and may return false even
114114
/// when the `Waker`s would awaken the same task. However, if this function

src/libstd/collections/hash/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use super::table::{self, Bucket, EmptyBucket, Fallibility, FullBucket, FullBucke
1919
use super::table::BucketState::{Empty, Full};
2020
use super::table::Fallibility::{Fallible, Infallible};
2121

22-
const MIN_NONZERO_RAW_CAPACITY: usize = 32; // must be a power of two
22+
const MIN_NONZERO_RAW_CAPACITY: usize = 32; // must be a power of two
2323

2424
/// The default behavior of HashMap implements a maximum load factor of 90.9%.
2525
#[derive(Clone)]

src/libstd/collections/hash/set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use super::Recover;
88
use super::map::{self, HashMap, Keys, RandomState};
99

1010
// Future Optimization (FIXME!)
11-
// =============================
11+
// ============================
1212
//
1313
// Iteration over zero sized values is a noop. There is no need
1414
// for `bucket.val` in the case of HashSet. I suppose we would need HKT

src/libstd/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ pub struct DirBuilder {
211211
recursive: bool,
212212
}
213213

214-
/// How large a buffer to pre-allocate before reading the entire file.
214+
/// Indicates how large a buffer to pre-allocate before reading the entire file.
215215
fn initial_buffer_size(file: &File) -> usize {
216216
// Allocate one extra byte so the buffer doesn't need to grow before the
217217
// final `read` call at the end of the file. Don't worry about `usize`

src/libstd/sync/condvar.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl Condvar {
190190
/// // Wait for the thread to start up.
191191
/// let &(ref lock, ref cvar) = &*pair;
192192
/// let mut started = lock.lock().unwrap();
193-
/// // As long as the value inside the `Mutex` is false, we wait.
193+
/// // As long as the value inside the `Mutex<bool>` is `false`, we wait.
194194
/// while !*started {
195195
/// started = cvar.wait(started).unwrap();
196196
/// }
@@ -254,7 +254,7 @@ impl Condvar {
254254
///
255255
/// // Wait for the thread to start up.
256256
/// let &(ref lock, ref cvar) = &*pair;
257-
/// // As long as the value inside the `Mutex` is false, we wait.
257+
/// // As long as the value inside the `Mutex<bool>` is `false`, we wait.
258258
/// let _guard = cvar.wait_until(lock.lock().unwrap(), |started| { *started }).unwrap();
259259
/// ```
260260
#[unstable(feature = "wait_until", issue = "47960")]
@@ -311,7 +311,7 @@ impl Condvar {
311311
/// // Wait for the thread to start up.
312312
/// let &(ref lock, ref cvar) = &*pair;
313313
/// let mut started = lock.lock().unwrap();
314-
/// // As long as the value inside the `Mutex` is false, we wait.
314+
/// // As long as the value inside the `Mutex<bool>` is `false`, we wait.
315315
/// loop {
316316
/// let result = cvar.wait_timeout_ms(started, 10).unwrap();
317317
/// // 10 milliseconds have passed, or maybe the value changed!
@@ -384,7 +384,7 @@ impl Condvar {
384384
/// // wait for the thread to start up
385385
/// let &(ref lock, ref cvar) = &*pair;
386386
/// let mut started = lock.lock().unwrap();
387-
/// // as long as the value inside the `Mutex` is false, we wait
387+
/// // as long as the value inside the `Mutex<bool>` is `false`, we wait
388388
/// loop {
389389
/// let result = cvar.wait_timeout(started, Duration::from_millis(10)).unwrap();
390390
/// // 10 milliseconds have passed, or maybe the value changed!
@@ -518,7 +518,7 @@ impl Condvar {
518518
/// // Wait for the thread to start up.
519519
/// let &(ref lock, ref cvar) = &*pair;
520520
/// let mut started = lock.lock().unwrap();
521-
/// // As long as the value inside the `Mutex` is false, we wait.
521+
/// // As long as the value inside the `Mutex<bool>` is `false`, we wait.
522522
/// while !*started {
523523
/// started = cvar.wait(started).unwrap();
524524
/// }
@@ -558,7 +558,7 @@ impl Condvar {
558558
/// // Wait for the thread to start up.
559559
/// let &(ref lock, ref cvar) = &*pair;
560560
/// let mut started = lock.lock().unwrap();
561-
/// // As long as the value inside the `Mutex` is false, we wait.
561+
/// // As long as the value inside the `Mutex<bool>` is `false`, we wait.
562562
/// while !*started {
563563
/// started = cvar.wait(started).unwrap();
564564
/// }

src/libstd/sys/windows/pipe.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ pub struct Pipes {
3737
///
3838
/// The ours/theirs pipes are *not* specifically readable or writable. Each
3939
/// one only supports a read or a write, but which is which depends on the
40-
/// boolean flag given. If `ours_readable` is true then `ours` is readable where
41-
/// `theirs` is writable. Conversely if `ours_readable` is false then `ours` is
42-
/// writable where `theirs` is readable.
40+
/// boolean flag given. If `ours_readable` is `true`, then `ours` is readable and
41+
/// `theirs` is writable. Conversely, if `ours_readable` is `false`, then `ours`
42+
/// is writable and `theirs` is readable.
4343
///
4444
/// Also note that the `ours` pipe is always a handle opened up in overlapped
4545
/// mode. This means that technically speaking it should only ever be used

0 commit comments

Comments
 (0)