Skip to content

Commit 3d3604b

Browse files
committed
ttrpc-codegen: fix clippy warnings on rust 1.81.0
Fix warnings. Signed-off-by: Tim Zhang <tim@hyper.sh>
1 parent ff13dea commit 3d3604b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

ttrpc-codegen/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl<'a> Run<'a> {
233233
protobuf_path: &str,
234234
result: &mut HashMap<String, FileDescriptorPair>,
235235
) {
236-
if result.get(protobuf_path).is_some() {
236+
if result.contains_key(protobuf_path) {
237237
return;
238238
}
239239

@@ -257,7 +257,7 @@ impl<'a> Run<'a> {
257257
}
258258

259259
fn add_file(&mut self, protobuf_path: &str, fs_path: &Path) -> io::Result<()> {
260-
if self.parsed_files.get(protobuf_path).is_some() {
260+
if self.parsed_files.contains_key(protobuf_path) {
261261
return Ok(());
262262
}
263263

ttrpc-codegen/src/parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ trait ToChar {
106106

107107
impl ToI32 for u64 {
108108
fn to_i32(&self) -> ParserResult<i32> {
109-
if *self <= i32::max_value() as u64 {
109+
if *self <= i32::MAX as u64 {
110110
Ok(*self as i32)
111111
} else {
112112
Err(ParserError::IntegerOverflow)
@@ -116,7 +116,7 @@ impl ToI32 for u64 {
116116

117117
impl ToI32 for i64 {
118118
fn to_i32(&self) -> ParserResult<i32> {
119-
if *self <= i32::max_value() as i64 && *self >= i32::min_value() as i64 {
119+
if *self <= i32::MAX as i64 && *self >= i32::MIN as i64 {
120120
Ok(*self as i32)
121121
} else {
122122
Err(ParserError::IntegerOverflow)
@@ -126,7 +126,7 @@ impl ToI32 for i64 {
126126

127127
impl ToI64 for u64 {
128128
fn to_i64(&self) -> Result<i64, ParserError> {
129-
if *self <= i64::max_value() as u64 {
129+
if *self <= i64::MAX as u64 {
130130
Ok(*self as i64)
131131
} else {
132132
Err(ParserError::IntegerOverflow)
@@ -1378,7 +1378,7 @@ impl<'a> Parser<'a> {
13781378
let from = self.next_field_number()?;
13791379
let to = if self.next_ident_if_eq("to")? {
13801380
if self.next_ident_if_eq("max")? {
1381-
i32::max_value()
1381+
i32::MAX
13821382
} else {
13831383
self.next_field_number()?
13841384
}

0 commit comments

Comments
 (0)