File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -1774,24 +1774,22 @@ declare_clippy_lint! {
17741774}
17751775
17761776declare_clippy_lint ! {
1777- /// **What it does:** Checks for usages of `splitn(2, _)`
1777+ /// **What it does:** Checks for usages of `str:: splitn(2, _)`
17781778 ///
1779- /// **Why is this bad?** `split_once` is clearer.
1779+ /// **Why is this bad?** `split_once` is both clearer in intent and slightly more efficient .
17801780 ///
17811781 /// **Known problems:** None.
17821782 ///
17831783 /// **Example:**
17841784 ///
1785- /// ```rust
1785+ /// ```rust,ignore
17861786 /// // Bad
1787- /// let some_str = "name=value";
1788- /// let mut iter = some_str.splitn(2, '=');
1789- /// let name = iter.next().unwrap();
1790- /// let value = iter.next().unwrap_or("");
1787+ /// let (key, value) = _.splitn(2, '=').next_tuple()?;
1788+ /// let value = _.splitn(2, '=').nth(1)?;
17911789 ///
17921790 /// // Good
1793- /// let some_str = "name=value" ;
1794- /// let (name, value) = some_str .split_once('=').unwrap_or((some_str, "")) ;
1791+ /// let (key, value) = _.split_once('=')? ;
1792+ /// let value = _ .split_once('=')?.1 ;
17951793 /// ```
17961794 pub MANUAL_SPLIT_ONCE ,
17971795 complexity,
You can’t perform that action at this time.
0 commit comments