Skip to content

Commit 17e106f

Browse files
authored
Rollup merge of rust-lang#40997 - donniebishop:from_utf8_linking, r=steveklabnik
Added links to types in from_utf8 description References rust-lang#29375. Link to types mentioned in the documentation for `from_utf8` (`str`, `&[u8`], etc). Paragraphs were reformatted to keep any one line from being excessively long, but are otherwise unchanged.
2 parents 03b81a1 + 364241c commit 17e106f

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/libcore/str/mod.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,15 @@ impl Utf8Error {
215215

216216
/// Converts a slice of bytes to a string slice.
217217
///
218-
/// A string slice (`&str`) is made of bytes (`u8`), and a byte slice (`&[u8]`)
219-
/// is made of bytes, so this function converts between the two. Not all byte
220-
/// slices are valid string slices, however: `&str` requires that it is valid
221-
/// UTF-8. `from_utf8()` checks to ensure that the bytes are valid UTF-8, and
222-
/// then does the conversion.
218+
/// A string slice ([`&str`]) is made of bytes ([`u8`]), and a byte slice
219+
/// ([`&[u8]`][byteslice]) is made of bytes, so this function converts between
220+
/// the two. Not all byte slices are valid string slices, however: [`&str`] requires
221+
/// that it is valid UTF-8. `from_utf8()` checks to ensure that the bytes are valid
222+
/// UTF-8, and then does the conversion.
223+
///
224+
/// [`&str`]: ../../std/primitive.str.html
225+
/// [`u8`]: ../../std/primitive.u8.html
226+
/// [byteslice]: ../../std/primitive.slice.html
223227
///
224228
/// If you are sure that the byte slice is valid UTF-8, and you don't want to
225229
/// incur the overhead of the validity check, there is an unsafe version of
@@ -233,9 +237,12 @@ impl Utf8Error {
233237
///
234238
/// [string]: ../../std/string/struct.String.html#method.from_utf8
235239
///
236-
/// Because you can stack-allocate a `[u8; N]`, and you can take a `&[u8]` of
237-
/// it, this function is one way to have a stack-allocated string. There is
238-
/// an example of this in the examples section below.
240+
/// Because you can stack-allocate a `[u8; N]`, and you can take a
241+
/// [`&[u8]`][byteslice] of it, this function is one way to have a
242+
/// stack-allocated string. There is an example of this in the
243+
/// examples section below.
244+
///
245+
/// [byteslice]: ../../std/primitive.slice.html
239246
///
240247
/// # Errors
241248
///

0 commit comments

Comments
 (0)