Auto merge of #11826 - kpreid:typo, r=Alexendoo

Fix typos in recent lint documentation.

Fixes typos and markup errors, and also makes the examples more realistic by hiding the `;`s so as not to visibly be discarding the computed value. Affected lints:

* `redundant_as_str`
* `unnecessary_map_on_constructor`

changelog: none
This commit is contained in:
bors 2023-11-18 19:49:46 +00:00
commit 6eb935a578
2 changed files with 13 additions and 8 deletions

View File

@ -3609,7 +3609,7 @@
declare_clippy_lint! { declare_clippy_lint! {
/// ### What it does /// ### What it does
/// Checks for usage of `as_str()` on a `String`` chained with a method available on the `String` itself. /// Checks for usage of `as_str()` on a `String` chained with a method available on the `String` itself.
/// ///
/// ### Why is this bad? /// ### Why is this bad?
/// The `as_str()` conversion is pointless and can be removed for simplicity and cleanliness. /// The `as_str()` conversion is pointless and can be removed for simplicity and cleanliness.
@ -3618,14 +3618,16 @@
/// ```no_run /// ```no_run
/// # #![allow(unused)] /// # #![allow(unused)]
/// let owned_string = "This is a string".to_owned(); /// let owned_string = "This is a string".to_owned();
/// owned_string.as_str().as_bytes(); /// owned_string.as_str().as_bytes()
/// # ;
/// ``` /// ```
/// ///
/// Use instead: /// Use instead:
/// ```no_run /// ```no_run
/// # #![allow(unused)] /// # #![allow(unused)]
/// let owned_string = "This is a string".to_owned(); /// let owned_string = "This is a string".to_owned();
/// owned_string.as_bytes(); /// owned_string.as_bytes()
/// # ;
/// ``` /// ```
#[clippy::version = "1.74.0"] #[clippy::version = "1.74.0"]
pub REDUNDANT_AS_STR, pub REDUNDANT_AS_STR,

View File

@ -9,19 +9,22 @@
declare_clippy_lint! { declare_clippy_lint! {
/// ### What it does /// ### What it does
/// Suggest removing the use of a map (or map_err) method when an Option or Result is being constructed. /// Suggests removing the use of a `map()` (or `map_err()`) method when an `Option` or `Result`
/// is being constructed.
/// ///
/// ### Why is this bad? /// ### Why is this bad?
/// It introduces unnecessary complexity. In this case the function can be used directly and /// It introduces unnecessary complexity. Instead, the function can be called before
/// construct the Option or Result from the output. /// constructing the `Option` or `Result` from its return value.
/// ///
/// ### Example /// ### Example
/// ```no_run /// ```no_run
/// Some(4).map(i32::swap_bytes); /// Some(4).map(i32::swap_bytes)
/// # ;
/// ``` /// ```
/// Use instead: /// Use instead:
/// ```no_run /// ```no_run
/// Some(i32::swap_bytes(4)); /// Some(i32::swap_bytes(4))
/// # ;
/// ``` /// ```
#[clippy::version = "1.74.0"] #[clippy::version = "1.74.0"]
pub UNNECESSARY_MAP_ON_CONSTRUCTOR, pub UNNECESSARY_MAP_ON_CONSTRUCTOR,