Skip to content

Commit

Permalink
Resolve get_first clippy lint
Browse files Browse the repository at this point in the history
    error: accessing first element with `bytes.get(0)`
       --> src/parse.rs:265:8
        |
    265 |     if bytes.get(0) == Some(&b'=') {
        |        ^^^^^^^^^^^^ help: try: `bytes.first()`
        |
        = note: `-D clippy::get-first` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

    error: accessing first element with `bytes.get(0)`
       --> src/parse.rs:267:15
        |
    267 |     } else if bytes.get(0) == Some(&b'>') {
        |               ^^^^^^^^^^^^ help: try: `bytes.first()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

    error: accessing first element with `bytes.get(0)`
       --> src/parse.rs:273:15
        |
    273 |     } else if bytes.get(0) == Some(&b'<') {
        |               ^^^^^^^^^^^^ help: try: `bytes.first()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

    error: accessing first element with `bytes.get(0)`
       --> src/parse.rs:279:15
        |
    279 |     } else if bytes.get(0) == Some(&b'~') {
        |               ^^^^^^^^^^^^ help: try: `bytes.first()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first

    error: accessing first element with `bytes.get(0)`
       --> src/parse.rs:281:15
        |
    281 |     } else if bytes.get(0) == Some(&b'^') {
        |               ^^^^^^^^^^^^ help: try: `bytes.first()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
  • Loading branch information
dtolnay committed Jun 7, 2022
1 parent eed5a41 commit 7a3e8f7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,23 +262,23 @@ fn identifier(input: &str, pos: Position) -> Result<(&str, &str), Error> {

fn op(input: &str) -> (Op, &str) {
let bytes = input.as_bytes();
if bytes.get(0) == Some(&b'=') {
if bytes.first() == Some(&b'=') {
(Op::Exact, &input[1..])
} else if bytes.get(0) == Some(&b'>') {
} else if bytes.first() == Some(&b'>') {
if bytes.get(1) == Some(&b'=') {
(Op::GreaterEq, &input[2..])
} else {
(Op::Greater, &input[1..])
}
} else if bytes.get(0) == Some(&b'<') {
} else if bytes.first() == Some(&b'<') {
if bytes.get(1) == Some(&b'=') {
(Op::LessEq, &input[2..])
} else {
(Op::Less, &input[1..])
}
} else if bytes.get(0) == Some(&b'~') {
} else if bytes.first() == Some(&b'~') {
(Op::Tilde, &input[1..])
} else if bytes.get(0) == Some(&b'^') {
} else if bytes.first() == Some(&b'^') {
(Op::Caret, &input[1..])
} else {
(Op::DEFAULT, input)
Expand Down

0 comments on commit 7a3e8f7

Please sign in to comment.