diff options
| author | bors <bors@rust-lang.org> | 2020-06-02 12:11:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-06-02 12:11:28 +0000 |
| commit | 5cb9ef390aea2a1adaae4b9836bb7a3a75c47f25 (patch) | |
| tree | 3264f79738b35896cde8fb12ed376fee02a4fad5 /clippy_lints/src/strings.rs | |
| parent | f760d77bdb2bff46f284500f77ecc697dd8507c5 (diff) | |
| parent | 137a3b4d3242cfe331f8f9b87c51ac0c431fe160 (diff) | |
Auto merge of #5664 - ThibsG:GiveCorrectedCode, r=flip1995
Give corrected code This PR adds corrected code for doc examples. I did this in several commits to facilitate review. Don't hesitate to tell me if I forgot some. Also, sometimes I felt it was not necessary to give corrected code, but I maybe wrong. fixes: #4829 changelog: Improve documentation examples across multiple lints.
Diffstat (limited to 'clippy_lints/src/strings.rs')
| -rw-r--r-- | clippy_lints/src/strings.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 2c51271e312..f84566ef707 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -24,6 +24,10 @@ declare_clippy_lint! { /// ```rust /// let mut x = "Hello".to_owned(); /// x = x + ", World"; + /// + /// // More readable + /// x += ", World"; + /// x.push_str(", World"); /// ``` pub STRING_ADD_ASSIGN, pedantic, @@ -69,7 +73,11 @@ declare_clippy_lint! { /// /// **Example:** /// ```rust + /// // Bad /// let bs = "a byte string".as_bytes(); + /// + /// // Good + /// let bs = b"a byte string"; /// ``` pub STRING_LIT_AS_BYTES, style, |
