Skip to content

Commit cd631a9

Browse files
authored
Rollup merge of #40935 - donniebishop:str_boilerplate_docs, r=steveklabnik
Modify str Structs descriptions References #29375. Modified descriptions of multiple structs to be more in line with structs found under [`std::iter`](https://doc.rust-lang.org/std/iter/#structs), such as [`Chain`](https://doc.rust-lang.org/std/iter/struct.Chain.html) and [`Enumerate`](https://doc.rust-lang.org/std/iter/struct.Enumerate.html)
2 parents f5d0105 + 3b39621 commit cd631a9

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

src/libcollections/str.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,15 @@ impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
133133
}
134134
}
135135

136-
/// External iterator for a string's UTF-16 code units.
136+
/// An iterator of [`u16`] over the string encoded as UTF-16.
137137
///
138-
/// For use with the `std::iter` module.
138+
/// [`u16`]: ../../std/primitive.u16.html
139+
///
140+
/// This struct is created by the [`encode_utf16`] method on [`str`].
141+
/// See its documentation for more.
142+
///
143+
/// [`encode_utf16`]: ../../std/primitive.str.html#method.encode_utf16
144+
/// [`str`]: ../../std/primitive.str.html
139145
#[derive(Clone)]
140146
#[stable(feature = "encode_utf16", since = "1.8.0")]
141147
pub struct EncodeUtf16<'a> {

src/libcore/str/mod.rs

+24-7
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,15 @@ impl fmt::Display for Utf8Error {
369369
Section: Iterators
370370
*/
371371

372-
/// Iterator for the char (representing *Unicode Scalar Values*) of a string.
372+
/// An iterator over the [`char`]s of a string slice.
373373
///
374-
/// Created with the method [`chars`].
374+
/// [`char`]: ../../std/primitive.char.html
375+
///
376+
/// This struct is created by the [`chars`] method on [`str`].
377+
/// See its documentation for more.
375378
///
376379
/// [`chars`]: ../../std/primitive.str.html#method.chars
380+
/// [`str`]: ../../std/primitive.str.html
377381
#[derive(Clone, Debug)]
378382
#[stable(feature = "rust1", since = "1.0.0")]
379383
pub struct Chars<'a> {
@@ -553,7 +557,15 @@ impl<'a> Chars<'a> {
553557
}
554558
}
555559

556-
/// Iterator for a string's characters and their byte offsets.
560+
/// An iterator over the [`char`]s of a string slice, and their positions.
561+
///
562+
/// [`char`]: ../../std/primitive.char.html
563+
///
564+
/// This struct is created by the [`char_indices`] method on [`str`].
565+
/// See its documentation for more.
566+
///
567+
/// [`char_indices`]: ../../std/primitive.str.html#method.char_indices
568+
/// [`str`]: ../../std/primitive.str.html
557569
#[derive(Clone, Debug)]
558570
#[stable(feature = "rust1", since = "1.0.0")]
559571
pub struct CharIndices<'a> {
@@ -625,12 +637,13 @@ impl<'a> CharIndices<'a> {
625637
}
626638
}
627639

628-
/// External iterator for a string's bytes.
629-
/// Use with the `std::iter` module.
640+
/// An iterator over the bytes of a string slice.
630641
///
631-
/// Created with the method [`bytes`].
642+
/// This struct is created by the [`bytes`] method on [`str`].
643+
/// See its documentation for more.
632644
///
633645
/// [`bytes`]: ../../std/primitive.str.html#method.bytes
646+
/// [`str`]: ../../std/primitive.str.html
634647
#[stable(feature = "rust1", since = "1.0.0")]
635648
#[derive(Clone, Debug)]
636649
pub struct Bytes<'a>(Cloned<slice::Iter<'a, u8>>);
@@ -1161,9 +1174,13 @@ generate_pattern_iterators! {
11611174
delegate double ended;
11621175
}
11631176

1164-
/// Created with the method [`lines`].
1177+
/// An iterator over the lines of a string, as string slices.
1178+
///
1179+
/// This struct is created with the [`lines`] method on [`str`].
1180+
/// See its documentation for more.
11651181
///
11661182
/// [`lines`]: ../../std/primitive.str.html#method.lines
1183+
/// [`str`]: ../../std/primitive.str.html
11671184
#[stable(feature = "rust1", since = "1.0.0")]
11681185
#[derive(Clone, Debug)]
11691186
pub struct Lines<'a>(Map<SplitTerminator<'a, char>, LinesAnyMap>);

src/libstd_unicode/u_str.rs

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ use core::str::Split;
1919

2020
/// An iterator over the non-whitespace substrings of a string,
2121
/// separated by any amount of whitespace.
22+
///
23+
/// This struct is created by the [`split_whitespace`] method on [`str`].
24+
/// See its documentation for more.
25+
///
26+
/// [`split_whitespace`]: ../../std/primitive.str.html#method.split_whitespace
27+
/// [`str`]: ../../std/primitive.str.html
2228
#[stable(feature = "split_whitespace", since = "1.1.0")]
2329
pub struct SplitWhitespace<'a> {
2430
inner: Filter<Split<'a, fn(char) -> bool>, fn(&&str) -> bool>,

0 commit comments

Comments
 (0)