Skip to content

Commit

Permalink
Use infallible from instead of try_from
Browse files Browse the repository at this point in the history
This is a new lint added in 1.75.0
https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_fallible_conversions

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
  • Loading branch information
gowthamsk-arm authored and tgonzalezorlandoarm committed Jan 16, 2024
1 parent 18572a8 commit 9f50ebb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/requests/common/wire_header_1_0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use arbitrary::Arbitrary;
use bincode::Options;
use log::error;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use std::io::{Read, Write};

const WIRE_PROTOCOL_VERSION_MAJ: u8 = 1;
Expand Down Expand Up @@ -120,7 +119,7 @@ impl WireHeader {
}

let hdr_size = get_from_stream!(stream, u16);
let mut bytes = vec![0_u8; usize::try_from(hdr_size)?];
let mut bytes = vec![0_u8; usize::from(hdr_size)];
stream.read_exact(&mut bytes)?;
if hdr_size != REQUEST_HDR_SIZE {
error!(
Expand Down
2 changes: 1 addition & 1 deletion src/requests/request/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Request {
return Err(ResponseStatus::BodySizeExceedsLimit);
}
let body = RequestBody::read_from_stream(stream, body_len)?;
let auth = RequestAuth::read_from_stream(stream, usize::try_from(raw_header.auth_len)?)?;
let auth = RequestAuth::read_from_stream(stream, usize::from(raw_header.auth_len))?;

Ok(Request {
header: raw_header.try_into()?,
Expand Down

0 comments on commit 9f50ebb

Please sign in to comment.