diff --git a/crates/bencher/src/common.rs b/crates/bencher/src/common.rs
index 6d17664..4e5b958 100644
--- a/crates/bencher/src/common.rs
+++ b/crates/bencher/src/common.rs
@@ -27,17 +27,11 @@ impl TaskSetCpuList {
let indicator = self.0.iter().map(|indicator| match indicator {
TaskSetCpuIndicator::Single(i) => i.to_string(),
TaskSetCpuIndicator::Range(range) => {
- format!(
- "{}-{}",
- range.start,
- range.clone().into_iter().last().unwrap()
- )
+ format!("{}-{}", range.start, range.clone().last().unwrap())
}
});
- Itertools::intersperse_with(indicator, || ",".to_string())
- .into_iter()
- .collect()
+ Itertools::intersperse_with(indicator, || ",".to_string()).collect()
}
pub fn new(
@@ -163,7 +157,7 @@ pub fn simple_load_test_runs(
workers: &[(usize, Priority)],
) -> Vec<(usize, Priority, TaskSetCpuList)> {
workers
- .into_iter()
+ .iter()
.copied()
.map(|(workers, priority)| {
(
diff --git a/crates/bencher/src/html.rs b/crates/bencher/src/html.rs
index 15a0b93..03278f3 100644
--- a/crates/bencher/src/html.rs
+++ b/crates/bencher/src/html.rs
@@ -191,7 +191,7 @@ pub fn html_all_runs(all_results: &[TrackerCoreCountResults]) -> String {
load_test_key_names = load_test_key_names.iter()
.map(|name| format!("
Load test {} | ", name))
.join("\n"),
- body = results.into_iter().map(|r| {
+ body = results.iter_mut().map(|r| {
formatdoc! {
"
diff --git a/crates/bencher/src/run.rs b/crates/bencher/src/run.rs
index 2757404..a28e62f 100644
--- a/crates/bencher/src/run.rs
+++ b/crates/bencher/src/run.rs
@@ -59,9 +59,7 @@ impl RunConfig {
.run(command, &self.tracker_vcpus, &mut tracker_config_file)
{
Ok(handle) => ChildWrapper(handle),
- Err(err) => {
- return Err(RunErrorResults::new(self).set_error(err.into(), "run tracker"))
- }
+ Err(err) => return Err(RunErrorResults::new(self).set_error(err, "run tracker")),
};
::std::thread::sleep(Duration::from_secs(1));
@@ -74,7 +72,7 @@ impl RunConfig {
Ok(handle) => ChildWrapper(handle),
Err(err) => {
return Err(RunErrorResults::new(self)
- .set_error(err.into(), "run load test")
+ .set_error(err, "run load test")
.set_tracker_outputs(tracker))
}
};
@@ -328,7 +326,7 @@ impl FromStr for ProcessStats {
type Err = ();
fn from_str(s: &str) -> Result {
- let mut parts = s.trim().split_whitespace();
+ let mut parts = s.split_whitespace();
let avg_cpu_utilization = parts.next().ok_or(())?.parse().map_err(|_| ())?;
let peak_rss_kb: f32 = parts.next().ok_or(())?.parse().map_err(|_| ())?;
diff --git a/crates/bencher/src/set.rs b/crates/bencher/src/set.rs
index a34a3e7..7ddeef2 100644
--- a/crates/bencher/src/set.rs
+++ b/crates/bencher/src/set.rs
@@ -73,13 +73,13 @@ pub fn run_sets(
(minutes / 60, minutes % 60)
};
- println!("");
+ println!();
println!("Total number of load test runs: {}", total_num_runs);
println!(
"Estimated duration: {} hours, {} minutes",
estimated_hours, estimated_minutes
);
- println!("");
+ println!();
let results = set_configs
.into_iter()
@@ -115,7 +115,7 @@ pub fn run_sets(
&load_test_gen,
load_test_parameters,
implementation,
- &tracker_run,
+ tracker_run,
tracker_vcpus.clone(),
load_test_vcpus,
)
diff --git a/crates/combined_binary/src/main.rs b/crates/combined_binary/src/main.rs
index 97fba0f..56eeddd 100644
--- a/crates/combined_binary/src/main.rs
+++ b/crates/combined_binary/src/main.rs
@@ -12,12 +12,12 @@ fn main() {
::std::process::exit(match run() {
Ok(()) => 0,
Err(None) => {
- print_help(|| gen_info(), None);
+ print_help(gen_info, None);
0
}
Err(opt_err @ Some(_)) => {
- print_help(|| gen_info(), opt_err);
+ print_help(gen_info, opt_err);
1
}
@@ -62,7 +62,7 @@ fn run() -> Result<(), Option> {
arg => {
let opt_err = if arg == "-h" || arg == "--help" {
None
- } else if arg.chars().next() == Some('-') {
+ } else if arg.starts_with('-') {
Some("First argument must be protocol".to_string())
} else {
Some("Invalid protocol".to_string())
diff --git a/crates/http/src/workers/socket/connection.rs b/crates/http/src/workers/socket/connection.rs
index b65487a..d44508a 100644
--- a/crates/http/src/workers/socket/connection.rs
+++ b/crates/http/src/workers/socket/connection.rs
@@ -383,7 +383,7 @@ where
let body_len = response
.write(&mut &mut self.response_buffer[position..])
- .map_err(|err| ConnectionError::ResponseBufferWrite(err))?;
+ .map_err(ConnectionError::ResponseBufferWrite)?;
position += body_len;
@@ -391,7 +391,7 @@ where
return Err(ConnectionError::ResponseBufferFull);
}
- (&mut self.response_buffer[position..position + 2]).copy_from_slice(b"\r\n");
+ self.response_buffer[position..position + 2].copy_from_slice(b"\r\n");
position += 2;
@@ -403,7 +403,7 @@ where
let start = RESPONSE_HEADER_A.len();
let end = start + RESPONSE_HEADER_B.len();
- (&mut self.response_buffer[start..end]).copy_from_slice(RESPONSE_HEADER_B);
+ self.response_buffer[start..end].copy_from_slice(RESPONSE_HEADER_B);
}
// Set content-len header value
@@ -415,7 +415,7 @@ where
let start = RESPONSE_HEADER_A.len();
let end = start + content_len_bytes.len();
- (&mut self.response_buffer[start..end]).copy_from_slice(content_len_bytes);
+ self.response_buffer[start..end].copy_from_slice(content_len_bytes);
}
// Write buffer to stream
diff --git a/crates/http/src/workers/socket/request.rs b/crates/http/src/workers/socket/request.rs
index 4412382..ec5f19f 100644
--- a/crates/http/src/workers/socket/request.rs
+++ b/crates/http/src/workers/socket/request.rs
@@ -52,7 +52,7 @@ fn parse_forwarded_header(
header_format: ReverseProxyPeerIpHeaderFormat,
headers: &[httparse::Header<'_>],
) -> anyhow::Result {
- for header in headers.into_iter().rev() {
+ for header in headers.iter().rev() {
if header.name == header_name {
match header_format {
ReverseProxyPeerIpHeaderFormat::LastAddress => {
diff --git a/crates/http/src/workers/swarm/storage.rs b/crates/http/src/workers/swarm/storage.rs
index 1aa9bfe..d9ff867 100644
--- a/crates/http/src/workers/swarm/storage.rs
+++ b/crates/http/src/workers/swarm/storage.rs
@@ -66,16 +66,14 @@ impl TorrentMaps {
valid_until,
);
- let response = AnnounceResponse {
+ AnnounceResponse {
complete: seeders,
incomplete: leechers,
announce_interval: config.protocol.peer_announce_interval,
peers: ResponsePeerListV4(response_peers),
peers6: ResponsePeerListV6(vec![]),
warning_message: None,
- };
-
- response
+ }
}
IpAddr::V6(peer_ip_address) => {
let (seeders, leechers, response_peers) = self
@@ -90,16 +88,14 @@ impl TorrentMaps {
valid_until,
);
- let response = AnnounceResponse {
+ AnnounceResponse {
complete: seeders,
incomplete: leechers,
announce_interval: config.protocol.peer_announce_interval,
peers: ResponsePeerListV4(vec![]),
peers6: ResponsePeerListV6(response_peers),
warning_message: None,
- };
-
- response
+ }
}
}
}
diff --git a/crates/http_load_test/src/utils.rs b/crates/http_load_test/src/utils.rs
index c3dab09..d22c2c1 100644
--- a/crates/http_load_test/src/utils.rs
+++ b/crates/http_load_test/src/utils.rs
@@ -19,7 +19,7 @@ pub fn create_random_request(
let items = [RequestType::Announce, RequestType::Scrape];
- let dist = WeightedIndex::new(&weights).expect("random request weighted index");
+ let dist = WeightedIndex::new(weights).expect("random request weighted index");
match items[dist.sample(rng)] {
RequestType::Announce => create_announce_request(config, state, rng),
@@ -37,7 +37,7 @@ fn create_announce_request(config: &Config, state: &LoadTestState, rng: &mut imp
}
};
- let info_hash_index = select_info_hash_index(config, &state, rng);
+ let info_hash_index = select_info_hash_index(config, state, rng);
Request::Announce(AnnounceRequest {
info_hash: state.info_hashes[info_hash_index],
@@ -57,7 +57,7 @@ fn create_scrape_request(config: &Config, state: &LoadTestState, rng: &mut impl
let mut scrape_hashes = Vec::with_capacity(5);
for _ in 0..5 {
- let info_hash_index = select_info_hash_index(config, &state, rng);
+ let info_hash_index = select_info_hash_index(config, state, rng);
scrape_hashes.push(state.info_hashes[info_hash_index]);
}
diff --git a/crates/http_protocol/src/request.rs b/crates/http_protocol/src/request.rs
index 865a448..2fd175c 100644
--- a/crates/http_protocol/src/request.rs
+++ b/crates/http_protocol/src/request.rs
@@ -86,7 +86,7 @@ impl AnnounceRequest {
let mut position = 0usize;
for equal_sign_index in ::memchr::memchr_iter(b'=', query_string_bytes) {
- let segment_end = ampersand_iter.next().unwrap_or_else(|| query_string.len());
+ let segment_end = ampersand_iter.next().unwrap_or(query_string.len());
let key = query_string
.get(position..equal_sign_index)
@@ -207,7 +207,7 @@ impl ScrapeRequest {
let mut position = 0usize;
for equal_sign_index in ::memchr::memchr_iter(b'=', query_string_bytes) {
- let segment_end = ampersand_iter.next().unwrap_or_else(|| query_string.len());
+ let segment_end = ampersand_iter.next().unwrap_or(query_string.len());
let key = query_string
.get(position..equal_sign_index)
@@ -348,7 +348,7 @@ mod tests {
let mut bytes = Vec::new();
bytes.extend_from_slice(b"GET ");
- bytes.extend_from_slice(&ANNOUNCE_REQUEST_PATH.as_bytes());
+ bytes.extend_from_slice(ANNOUNCE_REQUEST_PATH.as_bytes());
bytes.extend_from_slice(b" HTTP/1.1\r\n\r\n");
let parsed_request = Request::from_bytes(&bytes[..]).unwrap().unwrap();
@@ -362,7 +362,7 @@ mod tests {
let mut bytes = Vec::new();
bytes.extend_from_slice(b"GET ");
- bytes.extend_from_slice(&SCRAPE_REQUEST_PATH.as_bytes());
+ bytes.extend_from_slice(SCRAPE_REQUEST_PATH.as_bytes());
bytes.extend_from_slice(b" HTTP/1.1\r\n\r\n");
let parsed_request = Request::from_bytes(&bytes[..]).unwrap().unwrap();
diff --git a/crates/http_protocol/src/utils.rs b/crates/http_protocol/src/utils.rs
index 618eb02..51b2ac4 100644
--- a/crates/http_protocol/src/utils.rs
+++ b/crates/http_protocol/src/utils.rs
@@ -43,7 +43,7 @@ pub fn urldecode_20_bytes(value: &str) -> anyhow::Result<[u8; 20]> {
let hex = [first as u8, second as u8];
- hex::decode_to_slice(&hex, &mut out_arr[i..i + 1])
+ hex::decode_to_slice(hex, &mut out_arr[i..i + 1])
.map_err(|err| anyhow::anyhow!("hex decode error: {:?}", err))?;
} else {
out_arr[i] = c as u8;
diff --git a/crates/peer_id/src/lib.rs b/crates/peer_id/src/lib.rs
index dbc7fcf..304e1e5 100644
--- a/crates/peer_id/src/lib.rs
+++ b/crates/peer_id/src/lib.rs
@@ -234,7 +234,7 @@ mod tests {
let len = bytes.len();
- (&mut peer_id.0[..len]).copy_from_slice(bytes);
+ peer_id.0[..len].copy_from_slice(bytes);
peer_id
}
diff --git a/crates/udp/src/common.rs b/crates/udp/src/common.rs
index dbfc868..f803ea5 100644
--- a/crates/udp/src/common.rs
+++ b/crates/udp/src/common.rs
@@ -211,7 +211,7 @@ impl Statistics {
}
fn create_atomic_usize_vec(len: usize) -> Vec {
- ::std::iter::repeat_with(|| AtomicUsize::default())
+ ::std::iter::repeat_with(AtomicUsize::default)
.take(len)
.collect()
}
diff --git a/crates/udp/src/workers/socket/mio.rs b/crates/udp/src/workers/socket/mio.rs
index eddef10..beede61 100644
--- a/crates/udp/src/workers/socket/mio.rs
+++ b/crates/udp/src/workers/socket/mio.rs
@@ -205,7 +205,7 @@ impl SocketWorker {
if let Err(HandleRequestError::RequestChannelFull(failed_requests)) =
self.handle_request(pending_scrape_valid_until, request, src)
{
- self.pending_requests.extend(failed_requests.into_iter());
+ self.pending_requests.extend(failed_requests);
self.polling_mode = PollMode::SkipReceiving;
break;
diff --git a/crates/udp/src/workers/socket/storage.rs b/crates/udp/src/workers/socket/storage.rs
index 5ded3ac..f6cf088 100644
--- a/crates/udp/src/workers/socket/storage.rs
+++ b/crates/udp/src/workers/socket/storage.rs
@@ -44,7 +44,7 @@ impl PendingScrapeResponseSlab {
for (i, info_hash) in request.info_hashes.into_iter().enumerate() {
let split_request = split_requests
- .entry(SwarmWorkerIndex::from_info_hash(&config, info_hash))
+ .entry(SwarmWorkerIndex::from_info_hash(config, info_hash))
.or_insert_with(|| PendingScrapeRequest {
slab_key,
info_hashes: BTreeMap::new(),
diff --git a/crates/udp/src/workers/socket/validator.rs b/crates/udp/src/workers/socket/validator.rs
index 4b5fe56..c68d1ef 100644
--- a/crates/udp/src/workers/socket/validator.rs
+++ b/crates/udp/src/workers/socket/validator.rs
@@ -59,8 +59,8 @@ impl ConnectionValidator {
let mut connection_id_bytes = [0u8; 8];
- (&mut connection_id_bytes[..4]).copy_from_slice(&elapsed);
- (&mut connection_id_bytes[4..]).copy_from_slice(&hash);
+ connection_id_bytes[..4].copy_from_slice(&elapsed);
+ connection_id_bytes[4..].copy_from_slice(&hash);
ConnectionId::new(i64::from_ne_bytes(connection_id_bytes))
}
@@ -78,7 +78,7 @@ impl ConnectionValidator {
return false;
}
- let tracker_elapsed = u64::from(self.start_time.elapsed().as_secs());
+ let tracker_elapsed = self.start_time.elapsed().as_secs();
let client_elapsed = u64::from(u32::from_ne_bytes(elapsed));
let client_expiration_time = client_elapsed + self.max_connection_age;
diff --git a/crates/udp/src/workers/swarm/storage.rs b/crates/udp/src/workers/swarm/storage.rs
index 36441b2..0c1dcc2 100644
--- a/crates/udp/src/workers/swarm/storage.rs
+++ b/crates/udp/src/workers/swarm/storage.rs
@@ -365,13 +365,14 @@ impl SmallPeerMap {
self.0.retain(|(_, peer)| {
let keep = peer.valid_until.valid(now);
- if !keep && config.statistics.peer_clients {
- if let Err(_) =
- statistics_sender.try_send(StatisticsMessage::PeerRemoved(peer.peer_id))
- {
- // Should never happen in practice
- ::log::error!("Couldn't send StatisticsMessage::PeerRemoved");
- }
+ if !keep
+ && config.statistics.peer_clients
+ && statistics_sender
+ .try_send(StatisticsMessage::PeerRemoved(peer.peer_id))
+ .is_err()
+ {
+ // Should never happen in practice
+ ::log::error!("Couldn't send StatisticsMessage::PeerRemoved");
}
keep
@@ -480,13 +481,13 @@ impl LargePeerMap {
if peer.is_seeder {
self.num_seeders -= 1;
}
- if config.statistics.peer_clients {
- if let Err(_) =
- statistics_sender.try_send(StatisticsMessage::PeerRemoved(peer.peer_id))
- {
- // Should never happen in practice
- ::log::error!("Couldn't send StatisticsMessage::PeerRemoved");
- }
+ if config.statistics.peer_clients
+ && statistics_sender
+ .try_send(StatisticsMessage::PeerRemoved(peer.peer_id))
+ .is_err()
+ {
+ // Should never happen in practice
+ ::log::error!("Couldn't send StatisticsMessage::PeerRemoved");
}
}
diff --git a/crates/udp/tests/common/mod.rs b/crates/udp/tests/common/mod.rs
index 832d027..ee8e365 100644
--- a/crates/udp/tests/common/mod.rs
+++ b/crates/udp/tests/common/mod.rs
@@ -29,7 +29,7 @@ pub fn connect(socket: &UdpSocket, tracker_addr: SocketAddr) -> anyhow::Result ::anyhow::Result<()> {
let ip = if config.server_address.is_ipv6() {
Ipv6Addr::LOCALHOST.into()
+ } else if config.network.multiple_client_ipv4s {
+ Ipv4Addr::new(127, 0, 0, 1 + i).into()
} else {
- if config.network.multiple_client_ipv4s {
- Ipv4Addr::new(127, 0, 0, 1 + i).into()
- } else {
- Ipv4Addr::LOCALHOST.into()
- }
+ Ipv4Addr::LOCALHOST.into()
};
let addr = SocketAddr::new(ip, port);
diff --git a/crates/udp_protocol/src/common.rs b/crates/udp_protocol/src/common.rs
index a0043df..6c54cb2 100644
--- a/crates/udp_protocol/src/common.rs
+++ b/crates/udp_protocol/src/common.rs
@@ -104,15 +104,15 @@ pub struct Ipv4AddrBytes(pub [u8; 4]);
impl Ip for Ipv4AddrBytes {}
-impl Into for Ipv4AddrBytes {
- fn into(self) -> Ipv4Addr {
- Ipv4Addr::from(self.0)
+impl From for Ipv4Addr {
+ fn from(val: Ipv4AddrBytes) -> Self {
+ Ipv4Addr::from(val.0)
}
}
-impl Into for Ipv4Addr {
- fn into(self) -> Ipv4AddrBytes {
- Ipv4AddrBytes(self.octets())
+impl From for Ipv4AddrBytes {
+ fn from(val: Ipv4Addr) -> Self {
+ Ipv4AddrBytes(val.octets())
}
}
@@ -122,15 +122,15 @@ pub struct Ipv6AddrBytes(pub [u8; 16]);
impl Ip for Ipv6AddrBytes {}
-impl Into for Ipv6AddrBytes {
- fn into(self) -> Ipv6Addr {
- Ipv6Addr::from(self.0)
+impl From for Ipv6Addr {
+ fn from(val: Ipv6AddrBytes) -> Self {
+ Ipv6Addr::from(val.0)
}
}
-impl Into for Ipv6Addr {
- fn into(self) -> Ipv6AddrBytes {
- Ipv6AddrBytes(self.octets())
+impl From for Ipv6AddrBytes {
+ fn from(val: Ipv6Addr) -> Self {
+ Ipv6AddrBytes(val.octets())
}
}
diff --git a/crates/udp_protocol/src/response.rs b/crates/udp_protocol/src/response.rs
index 882a928..4e3353f 100644
--- a/crates/udp_protocol/src/response.rs
+++ b/crates/udp_protocol/src/response.rs
@@ -85,7 +85,7 @@ impl Response {
// Error
3 => {
let transaction_id = read_i32_ne(&mut bytes).map(TransactionId)?;
- let message = String::from_utf8_lossy(&bytes).into_owned().into();
+ let message = String::from_utf8_lossy(bytes).into_owned().into();
Ok((ErrorResponse {
transaction_id,
diff --git a/crates/ws/src/common.rs b/crates/ws/src/common.rs
index 3240546..aced74a 100644
--- a/crates/ws/src/common.rs
+++ b/crates/ws/src/common.rs
@@ -57,12 +57,12 @@ pub struct OutMessageMeta {
pub pending_scrape_id: Option,
}
-impl Into for InMessageMeta {
- fn into(self) -> OutMessageMeta {
+impl From for OutMessageMeta {
+ fn from(val: InMessageMeta) -> Self {
OutMessageMeta {
- out_message_consumer_id: self.out_message_consumer_id,
- connection_id: self.connection_id,
- pending_scrape_id: self.pending_scrape_id,
+ out_message_consumer_id: val.out_message_consumer_id,
+ connection_id: val.connection_id,
+ pending_scrape_id: val.pending_scrape_id,
}
}
}
diff --git a/crates/ws/src/workers/socket/connection.rs b/crates/ws/src/workers/socket/connection.rs
index 82d93ef..5250b79 100644
--- a/crates/ws/src/workers/socket/connection.rs
+++ b/crates/ws/src/workers/socket/connection.rs
@@ -77,7 +77,7 @@ impl ConnectionRunner {
clean_up_data.before_open();
let config = self.config.clone();
- let connection_id = self.connection_id.clone();
+ let connection_id = self.connection_id;
race(
async {
@@ -608,7 +608,7 @@ impl ConnectionCleanupData {
let mut announced_info_hashes = HashMap::new();
for (info_hash, peer_id) in self.announced_info_hashes.take().into_iter() {
- let consumer_index = calculate_in_message_consumer_index(&config, info_hash);
+ let consumer_index = calculate_in_message_consumer_index(config, info_hash);
announced_info_hashes
.entry(consumer_index)
diff --git a/crates/ws/src/workers/swarm/mod.rs b/crates/ws/src/workers/swarm/mod.rs
index 7788d12..7863abe 100644
--- a/crates/ws/src/workers/swarm/mod.rs
+++ b/crates/ws/src/workers/swarm/mod.rs
@@ -140,7 +140,7 @@ async fn handle_request_stream(
match in_message {
InMessage::AnnounceRequest(request) => {
torrents.borrow_mut().handle_announce_request(
- &config,
+ config,
&mut rng.borrow_mut(),
&mut out_messages,
server_start_instant,
@@ -150,7 +150,7 @@ async fn handle_request_stream(
}
InMessage::ScrapeRequest(request) => torrents
.borrow_mut()
- .handle_scrape_request(&config, &mut out_messages, meta, request),
+ .handle_scrape_request(config, &mut out_messages, meta, request),
};
for (meta, out_message) in out_messages {
diff --git a/crates/ws/src/workers/swarm/storage.rs b/crates/ws/src/workers/swarm/storage.rs
index 37cf153..d579ad9 100644
--- a/crates/ws/src/workers/swarm/storage.rs
+++ b/crates/ws/src/workers/swarm/storage.rs
@@ -248,7 +248,11 @@ impl TorrentMaps {
regarding_offer_id: offer_id,
};
- if let Some(_) = answer_receiver.expecting_answers.remove(&expecting_answer) {
+ if answer_receiver
+ .expecting_answers
+ .remove(&expecting_answer)
+ .is_some()
+ {
let answer_out_message = AnswerOutMessage {
action: AnnounceAction::Announce,
peer_id: request.peer_id,
@@ -426,13 +430,11 @@ impl TorrentMaps {
#[cfg(feature = "metrics")]
self.peers_gauge_ipv4.decrement(1.0);
}
- } else {
- if let Some(torrent_data) = self.ipv6.get_mut(&info_hash) {
- torrent_data.remove_peer(peer_id);
+ } else if let Some(torrent_data) = self.ipv6.get_mut(&info_hash) {
+ torrent_data.remove_peer(peer_id);
- #[cfg(feature = "metrics")]
- self.peers_gauge_ipv6.decrement(1.0);
- }
+ #[cfg(feature = "metrics")]
+ self.peers_gauge_ipv6.decrement(1.0);
}
}
}
diff --git a/crates/ws_load_test/src/network.rs b/crates/ws_load_test/src/network.rs
index 55da243..f4e1744 100644
--- a/crates/ws_load_test/src/network.rs
+++ b/crates/ws_load_test/src/network.rs
@@ -312,7 +312,7 @@ pub fn random_request_type(config: &Config, rng: &mut impl Rng) -> RequestType {
let items = [RequestType::Announce, RequestType::Scrape];
- let dist = WeightedIndex::new(&weights).expect("random request weighted index");
+ let dist = WeightedIndex::new(weights).expect("random request weighted index");
items[dist.sample(rng)]
}
diff --git a/crates/ws_protocol/src/common.rs b/crates/ws_protocol/src/common.rs
index f465f04..5c0a430 100644
--- a/crates/ws_protocol/src/common.rs
+++ b/crates/ws_protocol/src/common.rs
@@ -156,7 +156,7 @@ mod tests {
assert!(bytes.len() == 20);
- arr.copy_from_slice(&bytes[..]);
+ arr.copy_from_slice(bytes);
InfoHash(arr)
}
diff --git a/crates/ws_protocol/src/lib.rs b/crates/ws_protocol/src/lib.rs
index c61681a..6a4ed40 100644
--- a/crates/ws_protocol/src/lib.rs
+++ b/crates/ws_protocol/src/lib.rs
@@ -270,7 +270,7 @@ mod tests {
assert!(bytes.len() == 20);
- arr.copy_from_slice(&bytes[..]);
+ arr.copy_from_slice(bytes);
InfoHash(arr)
}
@@ -372,8 +372,6 @@ mod tests {
let success = info_hashes == deserialized;
- if !success {}
-
success
}
}