Skip to content

Commit 364241c

Browse files
committed
Added links to types in from_utf8 description
1 parent 5e122f5 commit 364241c

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
@@ -210,11 +210,15 @@ impl Utf8Error {
210210

211211
/// Converts a slice of bytes to a string slice.
212212
///
213-
/// A string slice (`&str`) is made of bytes (`u8`), and a byte slice (`&[u8]`)
214-
/// is made of bytes, so this function converts between the two. Not all byte
215-
/// slices are valid string slices, however: `&str` requires that it is valid
216-
/// UTF-8. `from_utf8()` checks to ensure that the bytes are valid UTF-8, and
217-
/// then does the conversion.
213+
/// A string slice ([`&str`]) is made of bytes ([`u8`]), and a byte slice
214+
/// ([`&[u8]`][byteslice]) is made of bytes, so this function converts between
215+
/// the two. Not all byte slices are valid string slices, however: [`&str`] requires
216+
/// that it is valid UTF-8. `from_utf8()` checks to ensure that the bytes are valid
217+
/// UTF-8, and then does the conversion.
218+
///
219+
/// [`&str`]: ../../std/primitive.str.html
220+
/// [`u8`]: ../../std/primitive.u8.html
221+
/// [byteslice]: ../../std/primitive.slice.html
218222
///
219223
/// If you are sure that the byte slice is valid UTF-8, and you don't want to
220224
/// incur the overhead of the validity check, there is an unsafe version of
@@ -228,9 +232,12 @@ impl Utf8Error {
228232
///
229233
/// [string]: ../../std/string/struct.String.html#method.from_utf8
230234
///
231-
/// Because you can stack-allocate a `[u8; N]`, and you can take a `&[u8]` of
232-
/// it, this function is one way to have a stack-allocated string. There is
233-
/// an example of this in the examples section below.
235+
/// Because you can stack-allocate a `[u8; N]`, and you can take a
236+
/// [`&[u8]`][byteslice] of it, this function is one way to have a
237+
/// stack-allocated string. There is an example of this in the
238+
/// examples section below.
239+
///
240+
/// [byteslice]: ../../std/primitive.slice.html
234241
///
235242
/// # Errors
236243
///

0 commit comments

Comments
 (0)