diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2021-08-15 16:27:59 -0400 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2021-08-16 09:35:03 -0400 |
| commit | aab3267412bd23cae4fd58e860b6b9a36de42448 (patch) | |
| tree | d3c75c7c542737932a2a93fec32135f2dc7c85cf | |
| parent | a7f376fbd3f30b58ec2bde5538b446eb4c2d615e (diff) | |
| download | rust-aab3267412bd23cae4fd58e860b6b9a36de42448.tar.gz rust-aab3267412bd23cae4fd58e860b6b9a36de42448.zip | |
Update docs for `manual_split_once`
| -rw-r--r-- | clippy_lints/src/methods/mod.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 15ad0325006..b6438bce874 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1774,24 +1774,22 @@ declare_clippy_lint! { } declare_clippy_lint! { - /// **What it does:** Checks for usages of `splitn(2, _)` + /// **What it does:** Checks for usages of `str::splitn(2, _)` /// - /// **Why is this bad?** `split_once` is clearer. + /// **Why is this bad?** `split_once` is both clearer in intent and slightly more efficient. /// /// **Known problems:** None. /// /// **Example:** /// - /// ```rust + /// ```rust,ignore /// // Bad - /// let some_str = "name=value"; - /// let mut iter = some_str.splitn(2, '='); - /// let name = iter.next().unwrap(); - /// let value = iter.next().unwrap_or(""); + /// let (key, value) = _.splitn(2, '=').next_tuple()?; + /// let value = _.splitn(2, '=').nth(1)?; /// /// // Good - /// let some_str = "name=value"; - /// let (name, value) = some_str.split_once('=').unwrap_or((some_str, "")); + /// let (key, value) = _.split_once('=')?; + /// let value = _.split_once('=')?.1; /// ``` pub MANUAL_SPLIT_ONCE, complexity, |
