提交 c9a9d7ac 编写于 作者: C Corey Farwell 提交者: GitHub

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)
......@@ -133,9 +133,15 @@ fn connect(&self, sep: &str) -> String {
}
}
/// External iterator for a string's UTF-16 code units.
/// An iterator of [`u16`] over the string encoded as UTF-16.
///
/// For use with the `std::iter` module.
/// [`u16`]: ../../std/primitive.u16.html
///
/// This struct is created by the [`encode_utf16`] method on [`str`].
/// See its documentation for more.
///
/// [`encode_utf16`]: ../../std/primitive.str.html#method.encode_utf16
/// [`str`]: ../../std/primitive.str.html
#[derive(Clone)]
#[stable(feature = "encode_utf16", since = "1.8.0")]
pub struct EncodeUtf16<'a> {
......
......@@ -369,11 +369,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Section: Iterators
*/
/// Iterator for the char (representing *Unicode Scalar Values*) of a string.
/// An iterator over the [`char`]s of a string slice.
///
/// Created with the method [`chars`].
/// [`char`]: ../../std/primitive.char.html
///
/// This struct is created by the [`chars`] method on [`str`].
/// See its documentation for more.
///
/// [`chars`]: ../../std/primitive.str.html#method.chars
/// [`str`]: ../../std/primitive.str.html
#[derive(Clone, Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Chars<'a> {
......@@ -553,7 +557,15 @@ pub fn as_str(&self) -> &'a str {
}
}
/// Iterator for a string's characters and their byte offsets.
/// An iterator over the [`char`]s of a string slice, and their positions.
///
/// [`char`]: ../../std/primitive.char.html
///
/// This struct is created by the [`char_indices`] method on [`str`].
/// See its documentation for more.
///
/// [`char_indices`]: ../../std/primitive.str.html#method.char_indices
/// [`str`]: ../../std/primitive.str.html
#[derive(Clone, Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct CharIndices<'a> {
......@@ -625,12 +637,13 @@ pub fn as_str(&self) -> &'a str {
}
}
/// External iterator for a string's bytes.
/// Use with the `std::iter` module.
/// An iterator over the bytes of a string slice.
///
/// Created with the method [`bytes`].
/// This struct is created by the [`bytes`] method on [`str`].
/// See its documentation for more.
///
/// [`bytes`]: ../../std/primitive.str.html#method.bytes
/// [`str`]: ../../std/primitive.str.html
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Clone, Debug)]
pub struct Bytes<'a>(Cloned<slice::Iter<'a, u8>>);
......@@ -1161,9 +1174,13 @@ fn next_back(&mut self) -> Option<&'a str>
delegate double ended;
}
/// Created with the method [`lines`].
/// An iterator over the lines of a string, as string slices.
///
/// This struct is created with the [`lines`] method on [`str`].
/// See its documentation for more.
///
/// [`lines`]: ../../std/primitive.str.html#method.lines
/// [`str`]: ../../std/primitive.str.html
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Clone, Debug)]
pub struct Lines<'a>(Map<SplitTerminator<'a, char>, LinesAnyMap>);
......
......@@ -19,6 +19,12 @@
/// An iterator over the non-whitespace substrings of a string,
/// separated by any amount of whitespace.
///
/// This struct is created by the [`split_whitespace`] method on [`str`].
/// See its documentation for more.
///
/// [`split_whitespace`]: ../../std/primitive.str.html#method.split_whitespace
/// [`str`]: ../../std/primitive.str.html
#[stable(feature = "split_whitespace", since = "1.1.0")]
pub struct SplitWhitespace<'a> {
inner: Filter<Split<'a, fn(char) -> bool>, fn(&&str) -> bool>,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册