clippy --fix

This commit is contained in:
Christien Rioux
2023-09-17 14:14:39 -04:00
parent 6a65b9adee
commit 8a1260ed48
11 changed files with 51 additions and 65 deletions

View File

@@ -262,7 +262,7 @@ impl AssemblyBuffer {
remote_addr: SocketAddr,
) -> NetworkResult<Option<Vec<u8>>> {
// If we receive a zero length frame, send it
if frame.len() == 0 {
if frame.is_empty() {
return NetworkResult::value(Some(frame.to_vec()));
}
@@ -338,10 +338,8 @@ impl AssemblyBuffer {
// If we are returning a message, see if there are any more assemblies for this peer
// If not, remove the peer
if out.is_some() {
if peer_messages.assemblies.len() == 0 {
e.remove();
}
if out.is_some() && peer_messages.assemblies.is_empty() {
e.remove();
}
NetworkResult::value(out)
}
@@ -361,7 +359,7 @@ impl AssemblyBuffer {
/// Add framing to chunk to send to the wire
fn frame_chunk(chunk: &[u8], offset: usize, message_len: usize, seq: SequenceType) -> Vec<u8> {
assert!(chunk.len() > 0);
assert!(!chunk.is_empty());
assert!(message_len <= MAX_LEN);
assert!(offset + chunk.len() <= message_len);
@@ -403,7 +401,7 @@ impl AssemblyBuffer {
}
// Do not frame or split anything zero bytes long, just send it
if data.len() == 0 {
if data.is_empty() {
return sender(data, remote_addr).await;
}

View File

@@ -41,7 +41,7 @@ fn must_encode_path(c: u8) -> bool {
fn is_valid_scheme<H: AsRef<str>>(host: H) -> bool {
let mut chars = host.as_ref().chars();
if let Some(ch) = chars.next() {
if !matches!(ch, 'A'..='Z' | 'a'..='z') {
if !ch.is_ascii_alphabetic() {
return false;
}
} else {

View File

@@ -242,10 +242,8 @@ pub fn compatible_unspecified_socket_addr(socket_addr: &SocketAddr) -> SocketAdd
pub fn listen_address_to_socket_addrs(listen_address: &str) -> Result<Vec<SocketAddr>, String> {
// If no address is specified, but the port is, use ipv4 and ipv6 unspecified
// If the address is specified, only use the specified port and fail otherwise
let ip_addrs = vec![
IpAddr::V4(Ipv4Addr::UNSPECIFIED),
IpAddr::V6(Ipv6Addr::UNSPECIFIED),
];
let ip_addrs = [IpAddr::V4(Ipv4Addr::UNSPECIFIED),
IpAddr::V6(Ipv6Addr::UNSPECIFIED)];
Ok(if let Some(portstr) = listen_address.strip_prefix(':') {
let port = portstr
@@ -354,7 +352,7 @@ pub unsafe fn unaligned_u8_vec_uninit(n_bytes: usize) -> Vec<u8> {
let ptr = unaligned.as_mut_ptr();
mem::forget(unaligned);
Vec::from_raw_parts(ptr as *mut u8, n_bytes, n_bytes)
Vec::from_raw_parts(ptr, n_bytes, n_bytes)
}
pub fn debug_backtrace() -> String {