mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-02-25 18:55:38 -06:00
clippy work
This commit is contained in:
@@ -430,3 +430,9 @@ impl AssemblyBuffer {
|
||||
Ok(NetworkResult::value(()))
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for AssemblyBuffer {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
let inner = self.inner.lock();
|
||||
inner.table.is_empty()
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
let inner = self.inner.lock();
|
||||
inner.table.len()
|
||||
@@ -154,3 +159,12 @@ where
|
||||
Some(AsyncTagLockGuard::new(self.clone(), tag, guard))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Default for AsyncTagLockTable<T>
|
||||
where
|
||||
T: Hash + Eq + Clone + Debug,
|
||||
{
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
//! * `rt-async-std` - Uses `async-std` as the async runtime
|
||||
//! * `rt-wasm-bindgen` - When building for the `wasm32` architecture, use this to enable `wasm-bindgen-futures` as the async runtime
|
||||
//!
|
||||
#![deny(clippy::all)]
|
||||
#![allow(clippy::comparison_chain, clippy::upper_case_acronyms)]
|
||||
#![deny(unused_must_use)]
|
||||
|
||||
// pub mod bump_port;
|
||||
pub mod assembly_buffer;
|
||||
|
||||
@@ -68,29 +68,32 @@ cfg_if! {
|
||||
let show_month = show_year || now.month() != date.month();
|
||||
let show_date = show_month || now.day() != date.day();
|
||||
|
||||
let s_year = if show_year {
|
||||
format!("{:04}/",date.year())
|
||||
} else {
|
||||
"".to_owned()
|
||||
};
|
||||
let s_month = if show_month {
|
||||
format!("{:02}/",date.month())
|
||||
} else {
|
||||
"".to_owned()
|
||||
};
|
||||
let s_date = if show_date {
|
||||
format!("{:02}-",date.day())
|
||||
} else {
|
||||
"".to_owned()
|
||||
};
|
||||
let s_time = format!("{:02}:{:02}:{:02}.{:04}",
|
||||
date.hour(),
|
||||
date.minute(),
|
||||
date.second(),
|
||||
date.nanosecond()/1_000_000
|
||||
);
|
||||
format!("{}{}{}{}",
|
||||
if show_year {
|
||||
format!("{:04}/",date.year())
|
||||
} else {
|
||||
"".to_owned()
|
||||
},
|
||||
if show_month {
|
||||
format!("{:02}/",date.month())
|
||||
} else {
|
||||
"".to_owned()
|
||||
},
|
||||
if show_date {
|
||||
format!("{:02}-",date.day())
|
||||
} else {
|
||||
"".to_owned()
|
||||
},
|
||||
format!("{:02}:{:02}:{:02}.{:04}",
|
||||
date.hour(),
|
||||
date.minute(),
|
||||
date.second(),
|
||||
date.nanosecond()/1_000_000
|
||||
))
|
||||
|
||||
s_year,
|
||||
s_month,
|
||||
s_date,
|
||||
s_time)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,8 +242,10 @@ 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 = [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
|
||||
@@ -333,6 +335,8 @@ cfg_if::cfg_if! {
|
||||
#[repr(C, align(8))]
|
||||
struct AlignToEight([u8; 8]);
|
||||
|
||||
/// # Safety
|
||||
/// Ensure you immediately initialize this vector as it could contain sensitive data
|
||||
pub unsafe fn aligned_8_u8_vec_uninit(n_bytes: usize) -> Vec<u8> {
|
||||
let n_units = (n_bytes + mem::size_of::<AlignToEight>() - 1) / mem::size_of::<AlignToEight>();
|
||||
let mut aligned: Vec<AlignToEight> = Vec::with_capacity(n_units);
|
||||
@@ -347,6 +351,8 @@ pub unsafe fn aligned_8_u8_vec_uninit(n_bytes: usize) -> Vec<u8> {
|
||||
)
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
/// Ensure you immediately initialize this vector as it could contain sensitive data
|
||||
pub unsafe fn unaligned_u8_vec_uninit(n_bytes: usize) -> Vec<u8> {
|
||||
let mut unaligned: Vec<u8> = Vec::with_capacity(n_bytes);
|
||||
let ptr = unaligned.as_mut_ptr();
|
||||
|
||||
Reference in New Issue
Block a user