Skip to content

Commit

Permalink
Resolve question_mark clippy lint
Browse files Browse the repository at this point in the history
    warning: this `match` expression can be replaced with `?`
       --> src/generics.rs:191:20
        |
    191 |           let next = match self.0.next() {
        |  ____________________^
    192 | |             Some(item) => item,
    193 | |             None => return None,
    194 | |         };
        | |_________^ help: try instead: `self.0.next()?`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
        = note: `-W clippy::question-mark` implied by `-W clippy::all`
        = help: to override `-W clippy::all` add `#[allow(clippy::question_mark)]`

    warning: this `match` expression can be replaced with `?`
       --> src/generics.rs:209:20
        |
    209 |           let next = match self.0.next() {
        |  ____________________^
    210 | |             Some(item) => item,
    211 | |             None => return None,
    212 | |         };
        | |_________^ help: try instead: `self.0.next()?`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark

    warning: this `match` expression can be replaced with `?`
       --> src/generics.rs:227:20
        |
    227 |           let next = match self.0.next() {
        |  ____________________^
    228 | |             Some(item) => item,
    229 | |             None => return None,
    230 | |         };
        | |_________^ help: try instead: `self.0.next()?`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark

    warning: this `match` expression can be replaced with `?`
       --> src/generics.rs:245:20
        |
    245 |           let next = match self.0.next() {
        |  ____________________^
    246 | |             Some(item) => item,
    247 | |             None => return None,
    248 | |         };
        | |_________^ help: try instead: `self.0.next()?`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark

    warning: this `match` expression can be replaced with `?`
       --> src/generics.rs:263:20
        |
    263 |           let next = match self.0.next() {
        |  ____________________^
    264 | |             Some(item) => item,
    265 | |             None => return None,
    266 | |         };
        | |_________^ help: try instead: `self.0.next()?`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark

    warning: this `match` expression can be replaced with `?`
       --> src/generics.rs:281:20
        |
    281 |           let next = match self.0.next() {
        |  ____________________^
    282 | |             Some(item) => item,
    283 | |             None => return None,
    284 | |         };
        | |_________^ help: try instead: `self.0.next()?`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
  • Loading branch information
dtolnay committed Nov 16, 2024
1 parent 5c1c057 commit 0ccac34
Showing 1 changed file with 6 additions and 30 deletions.
36 changes: 6 additions & 30 deletions src/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,7 @@ impl<'a> Iterator for Lifetimes<'a> {
type Item = &'a LifetimeParam;

fn next(&mut self) -> Option<Self::Item> {
let next = match self.0.next() {
Some(item) => item,
None => return None,
};
if let GenericParam::Lifetime(lifetime) = next {
if let GenericParam::Lifetime(lifetime) = self.0.next()? {
Some(lifetime)
} else {
self.next()
Expand All @@ -206,11 +202,7 @@ impl<'a> Iterator for LifetimesMut<'a> {
type Item = &'a mut LifetimeParam;

fn next(&mut self) -> Option<Self::Item> {
let next = match self.0.next() {
Some(item) => item,
None => return None,
};
if let GenericParam::Lifetime(lifetime) = next {
if let GenericParam::Lifetime(lifetime) = self.0.next()? {
Some(lifetime)
} else {
self.next()
Expand All @@ -224,11 +216,7 @@ impl<'a> Iterator for TypeParams<'a> {
type Item = &'a TypeParam;

fn next(&mut self) -> Option<Self::Item> {
let next = match self.0.next() {
Some(item) => item,
None => return None,
};
if let GenericParam::Type(type_param) = next {
if let GenericParam::Type(type_param) = self.0.next()? {
Some(type_param)
} else {
self.next()
Expand All @@ -242,11 +230,7 @@ impl<'a> Iterator for TypeParamsMut<'a> {
type Item = &'a mut TypeParam;

fn next(&mut self) -> Option<Self::Item> {
let next = match self.0.next() {
Some(item) => item,
None => return None,
};
if let GenericParam::Type(type_param) = next {
if let GenericParam::Type(type_param) = self.0.next()? {
Some(type_param)
} else {
self.next()
Expand All @@ -260,11 +244,7 @@ impl<'a> Iterator for ConstParams<'a> {
type Item = &'a ConstParam;

fn next(&mut self) -> Option<Self::Item> {
let next = match self.0.next() {
Some(item) => item,
None => return None,
};
if let GenericParam::Const(const_param) = next {
if let GenericParam::Const(const_param) = self.0.next()? {
Some(const_param)
} else {
self.next()
Expand All @@ -278,11 +258,7 @@ impl<'a> Iterator for ConstParamsMut<'a> {
type Item = &'a mut ConstParam;

fn next(&mut self) -> Option<Self::Item> {
let next = match self.0.next() {
Some(item) => item,
None => return None,
};
if let GenericParam::Const(const_param) = next {
if let GenericParam::Const(const_param) = self.0.next()? {
Some(const_param)
} else {
self.next()
Expand Down

0 comments on commit 0ccac34

Please sign in to comment.