Merge pull request #24 from imp/clippy

Assorted clippy cleanups
This commit is contained in:
Igor Katson 2023-08-08 09:39:55 +01:00 committed by GitHub
commit 35b4871c52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 10 deletions

View file

@ -498,7 +498,6 @@ impl DhtWorker {
let mut futs = FuturesUnordered::new();
// bootstrap
for addr in bootstrap_addrs.iter() {
let addr = addr;
let this = &self;
let in_tx = &in_tx;
futs.push(async move {

View file

@ -59,7 +59,7 @@ impl ChunkTracker {
pub fn new(needed_pieces: BF, have_pieces: BF, lengths: Lengths) -> Self {
// TODO: ideally this needs to be a list based on needed files, e.g.
// last needed piece for each file. But let's keep simple for now.
let last_needed_piece_id = needed_pieces.iter_ones().rev().next();
let last_needed_piece_id = needed_pieces.iter_ones().next_back();
// The last pieces first. Often important information is stored in the last piece.
// E.g. if it's a video file, than the last piece often contains some index, or just

View file

@ -160,7 +160,7 @@ fn make_lengths<ByteBuf: AsRef<[u8]>>(
Lengths::new(total_length, torrent.piece_length, None)
}
fn ensure_file_length(file: &mut File, length: u64) -> anyhow::Result<()> {
fn ensure_file_length(file: &File, length: u64) -> anyhow::Result<()> {
Ok(file.set_len(length)?)
}
@ -237,7 +237,7 @@ impl TorrentManager {
continue;
}
let now = Instant::now();
if let Err(err) = ensure_file_length(&mut file.lock(), length) {
if let Err(err) = ensure_file_length(&file.lock(), length) {
warn!(
"Error setting length for file {:?} to {}: {:#?}",
name, length, err

View file

@ -132,12 +132,10 @@ impl<'a, ByteBuf: 'a> UtMetadata<ByteBuf> {
}
Ok(UtMetadata::Reject(message.piece))
}
other => {
return Err(MessageDeserializeError::Other(anyhow::anyhow!(
"unrecognized ut_metadata message type {}",
other
)))
}
other => Err(MessageDeserializeError::Other(anyhow::anyhow!(
"unrecognized ut_metadata message type {}",
other
))),
}
}
}