@@ -1952,6 +1952,34 @@ declare_clippy_lint! {
19521952 "finds patterns that can be encoded more concisely with `Option::ok_or`"
19531953}
19541954
1955+ declare_clippy_lint ! {
1956+ /// ### What it does
1957+ /// Checks for usage of `a.and_then(|a| b.map(|b| (a, b)))` which can be
1958+ /// more concisely expressed as `a.zip(b)`.
1959+ ///
1960+ /// ### Why is this bad?
1961+ /// `Option::zip` is more concise and directly expresses the intent of
1962+ /// combining two `Option` values into a tuple.
1963+ ///
1964+ /// ### Example
1965+ /// ```no_run
1966+ /// let a: Option<i32> = Some(1);
1967+ /// let b: Option<i32> = Some(2);
1968+ /// let _ = a.and_then(|x| b.map(|y| (x, y)));
1969+ /// ```
1970+ ///
1971+ /// Use instead:
1972+ /// ```no_run
1973+ /// let a: Option<i32> = Some(1);
1974+ /// let b: Option<i32> = Some(2);
1975+ /// let _ = a.zip(b);
1976+ /// ```
1977+ #[ clippy:: version = "1.95.0" ]
1978+ pub MANUAL_OPTION_ZIP ,
1979+ complexity,
1980+ "manual reimplementation of `Option::zip`"
1981+ }
1982+
19551983declare_clippy_lint ! {
19561984 /// ### What it does
19571985 ///
@@ -2116,34 +2144,6 @@ declare_clippy_lint! {
21162144 "combine `.map(_)` followed by `.all(identity)`/`.any(identity)` into a single call"
21172145}
21182146
2119- declare_clippy_lint ! {
2120- /// ### What it does
2121- /// Checks for usage of `a.and_then(|a| b.map(|b| (a, b)))` which can be
2122- /// more concisely expressed as `a.zip(b)`.
2123- ///
2124- /// ### Why is this bad?
2125- /// `Option::zip` is more concise and directly expresses the intent of
2126- /// combining two `Option` values into a tuple.
2127- ///
2128- /// ### Example
2129- /// ```no_run
2130- /// let a: Option<i32> = Some(1);
2131- /// let b: Option<i32> = Some(2);
2132- /// let _ = a.and_then(|x| b.map(|y| (x, y)));
2133- /// ```
2134- ///
2135- /// Use instead:
2136- /// ```no_run
2137- /// let a: Option<i32> = Some(1);
2138- /// let b: Option<i32> = Some(2);
2139- /// let _ = a.zip(b);
2140- /// ```
2141- #[ clippy:: version = "1.95.0" ]
2142- pub MANUAL_OPTION_ZIP ,
2143- complexity,
2144- "manual reimplementation of `Option::zip`"
2145- }
2146-
21472147declare_clippy_lint ! {
21482148 /// ### What it does
21492149 /// Checks for usage of `map(|x| x.clone())` or
0 commit comments