diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-04-05 12:44:30 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-05 12:44:30 -0400 |
| commit | 325848abe468ddd834539a06d191de067157d4cb (patch) | |
| tree | 56b72171e54adaffed6586bdeb8420f1bacdfd9f /src/libcore | |
| parent | fd474f0b2ec94f5ea2e1dd17c98b310b9c918c8d (diff) | |
| parent | 364241c709b3b769a0515b07b21c5748818291d8 (diff) | |
| download | rust-325848abe468ddd834539a06d191de067157d4cb.tar.gz rust-325848abe468ddd834539a06d191de067157d4cb.zip | |
Rollup merge of #40997 - donniebishop:from_utf8_linking, r=steveklabnik
Added links to types in from_utf8 description References #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.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/str/mod.rs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index a31c7347a60..352cc926994 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -215,11 +215,15 @@ impl Utf8Error { /// Converts a slice of bytes to a string slice. /// -/// A string slice (`&str`) is made of bytes (`u8`), and a byte slice (`&[u8]`) -/// is made of bytes, so this function converts between the two. Not all byte -/// slices are valid string slices, however: `&str` requires that it is valid -/// UTF-8. `from_utf8()` checks to ensure that the bytes are valid UTF-8, and -/// then does the conversion. +/// A string slice ([`&str`]) is made of bytes ([`u8`]), and a byte slice +/// ([`&[u8]`][byteslice]) is made of bytes, so this function converts between +/// the two. Not all byte slices are valid string slices, however: [`&str`] requires +/// that it is valid UTF-8. `from_utf8()` checks to ensure that the bytes are valid +/// UTF-8, and then does the conversion. +/// +/// [`&str`]: ../../std/primitive.str.html +/// [`u8`]: ../../std/primitive.u8.html +/// [byteslice]: ../../std/primitive.slice.html /// /// If you are sure that the byte slice is valid UTF-8, and you don't want to /// incur the overhead of the validity check, there is an unsafe version of @@ -233,9 +237,12 @@ impl Utf8Error { /// /// [string]: ../../std/string/struct.String.html#method.from_utf8 /// -/// Because you can stack-allocate a `[u8; N]`, and you can take a `&[u8]` of -/// it, this function is one way to have a stack-allocated string. There is -/// an example of this in the examples section below. +/// Because you can stack-allocate a `[u8; N]`, and you can take a +/// [`&[u8]`][byteslice] of it, this function is one way to have a +/// stack-allocated string. There is an example of this in the +/// examples section below. +/// +/// [byteslice]: ../../std/primitive.slice.html /// /// # Errors /// |
