mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
Known problems
This commit is contained in:
parent
7fa27d9387
commit
b9f272cdc2
1 changed files with 11 additions and 2 deletions
|
@ -96,11 +96,20 @@ declare_lint! {
|
|||
"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.
|
||||
///
|
||||
/// **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:**
|
||||
/// ```rust
|
||||
|
|
Loading…
Reference in a new issue