Known problems

This commit is contained in:
sinkuu 2017-11-01 21:10:48 +09:00
parent 7fa27d9387
commit b9f272cdc2

View file

@ -96,11 +96,20 @@ declare_lint! {
"transmutes from an integer to a `char`" "transmutes from an integer to a `char`"
} }
/// **What it does:** Checks for transmutes from a `&[u8] to a `&str`. /// **What it does:** Checks for transmutes from a `&[u8]` to a `&str`.
/// ///
/// **Why is this bad?** Not every byte slice is a valid UTF-8 string. /// **Why is this bad?** Not every byte slice is a valid UTF-8 string.
/// ///
/// **Known problems:** None. /// **Known problems:**
/// - [`from_utf8`] which this lint suggests using is slower than `transmute`
/// as it needs to validate the input.
/// If you are certain that the input is always a valid UTF-8,
/// use [`from_utf8_unchecked`] which is as fast as `transmute`
/// but has a semantically meaningful name.
/// - You might want to handle errors returned from [`from_utf8`] instead of calling `unwrap`.
///
/// [`from_utf8`]: https://doc.rust-lang.org/std/str/fn.from_utf8.html
/// [`from_utf8_unchecked`]: https://doc.rust-lang.org/std/str/fn.from_utf8_unchecked.html
/// ///
/// **Example:** /// **Example:**
/// ```rust /// ```rust