Skip to content

Commit

Permalink
Move Precedence's trait impls next to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed May 10, 2024
1 parent 4b052ad commit 9e85505
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,7 @@ pub(crate) fn requires_terminator(expr: &Expr) -> bool {
#[cfg(feature = "parsing")]
mod precedence {
use super::BinOp;
use std::cmp::Ordering;

pub(crate) enum Precedence {
Any,
Expand Down Expand Up @@ -1195,6 +1196,28 @@ mod precedence {
}
}
}

impl Copy for Precedence {}

impl Clone for Precedence {
fn clone(&self) -> Self {
*self
}
}

impl PartialEq for Precedence {
fn eq(&self, other: &Self) -> bool {
*self as u8 == *other as u8
}
}

impl PartialOrd for Precedence {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
let this = *self as u8;
let other = *other as u8;
Some(this.cmp(&other))
}
}
}

#[cfg(feature = "parsing")]
Expand Down Expand Up @@ -1243,7 +1266,6 @@ pub(crate) mod parsing {
use crate::verbatim;
#[cfg(feature = "full")]
use proc_macro2::TokenStream;
use std::cmp::Ordering;
use std::mem;

mod kw {
Expand Down Expand Up @@ -1341,28 +1363,6 @@ pub(crate) mod parsing {
}
}

impl Copy for Precedence {}

impl Clone for Precedence {
fn clone(&self) -> Self {
*self
}
}

impl PartialEq for Precedence {
fn eq(&self, other: &Self) -> bool {
*self as u8 == *other as u8
}
}

impl PartialOrd for Precedence {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
let this = *self as u8;
let other = *other as u8;
Some(this.cmp(&other))
}
}

#[cfg(feature = "full")]
fn can_begin_expr(input: ParseStream) -> bool {
input.peek(Ident::peek_any) // value name or keyword
Expand Down

0 comments on commit 9e85505

Please sign in to comment.