Cargo clippy: fix the majority of errors
This commit is contained in:
parent
871d927596
commit
6968a4e449
19 changed files with 69 additions and 91 deletions
|
|
@ -22,7 +22,7 @@ impl std::fmt::Debug for Id20 {
|
|||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "<")?;
|
||||
for byte in self.0 {
|
||||
write!(f, "{:02x?}", byte)?;
|
||||
write!(f, "{byte:02x?}")?;
|
||||
}
|
||||
write!(f, ">")?;
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ impl Lengths {
|
|||
if total_length == 0 {
|
||||
anyhow::bail!("torrent with 0 length")
|
||||
}
|
||||
let total_pieces = ceil_div_u64(total_length as u64, piece_length as u64) as u32;
|
||||
let total_pieces = ceil_div_u64(total_length, piece_length as u64) as u32;
|
||||
Ok(Self {
|
||||
chunk_length,
|
||||
piece_length,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ fn try_decode_azureus_style(p: &Id20) -> Option<AzureusStyle> {
|
|||
return None;
|
||||
}
|
||||
let mut version = ['0'; 4];
|
||||
for (i, c) in (&p[3..7]).iter().copied().enumerate() {
|
||||
for (i, c) in p[3..7].iter().copied().enumerate() {
|
||||
version[i] = c as char;
|
||||
}
|
||||
let kind = AzureusStyleKind::from_bytes(p[1], p[2]);
|
||||
|
|
@ -51,9 +51,9 @@ pub fn generate_peer_id() -> Id20 {
|
|||
let mut peer_id = [0u8; 20];
|
||||
|
||||
let u = uuid::Uuid::new_v4();
|
||||
(&mut peer_id[4..20]).copy_from_slice(&u.as_bytes()[..]);
|
||||
peer_id[4..20].copy_from_slice(&u.as_bytes()[..]);
|
||||
|
||||
(&mut peer_id[..8]).copy_from_slice(b"-rQ0001-");
|
||||
peer_id[..8].copy_from_slice(b"-rQ0001-");
|
||||
|
||||
Id20(peer_id)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ where
|
|||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self.to_string() {
|
||||
Ok(s) => write!(f, "{:?}", s),
|
||||
Err(e) => write!(f, "<{:?}>", e),
|
||||
Ok(s) => write!(f, "{s:?}"),
|
||||
Err(e) => write!(f, "<{e:?}>"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue