Skip to content

Commit

Permalink
ttrpc-codegen: Fix clippy error manual_find
Browse files Browse the repository at this point in the history
Got:

error: manual implementation of `Iterator::find`
   --> src/parser.rs:354:9
    |
354 | /         for c in alphabet.chars() {
355 | |             if self.next_char_if_eq(c) {
356 | |                 return Some(c);
357 | |             }
358 | |         }
359 | |         None
    | |____________^ help: replace with an iterator: `alphabet.chars().find(|&c| self.next_char_if_eq(c))`
    |
    = note: `-D clippy::manual-find` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_find

This commit will fix the problem.

Signed-off-by: Tim Zhang <[email protected]>
  • Loading branch information
Tim-Zhang committed Oct 14, 2022
1 parent 68209fa commit a42b31c
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions ttrpc-codegen/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,7 @@ impl<'a> Lexer<'a> {
}

fn next_char_if_in(&mut self, alphabet: &str) -> Option<char> {
for c in alphabet.chars() {
if self.next_char_if_eq(c) {
return Some(c);
}
}
None
alphabet.chars().find(|&c| self.next_char_if_eq(c))
}

fn next_char_expect_eq(&mut self, expect: char) -> ParserResult<()> {
Expand Down

0 comments on commit a42b31c

Please sign in to comment.