mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Meaningful changes from aggressive-clippy
I do want to enable a few specific lints, yet aggressive-clippy as a whole isn't worthwhile.
This commit is contained in:
@@ -23,7 +23,7 @@ pub trait Db: 'static + Send + Sync + Clone + Debug + Get {
|
||||
fn key(db_dst: &'static [u8], item_dst: &'static [u8], key: impl AsRef<[u8]>) -> Vec<u8> {
|
||||
let db_len = u8::try_from(db_dst.len()).unwrap();
|
||||
let dst_len = u8::try_from(item_dst.len()).unwrap();
|
||||
[[db_len].as_ref(), db_dst, [dst_len].as_ref(), item_dst, key.as_ref()].concat().to_vec()
|
||||
[[db_len].as_ref(), db_dst, [dst_len].as_ref(), item_dst, key.as_ref()].concat()
|
||||
}
|
||||
fn txn(&mut self) -> Self::Transaction<'_>;
|
||||
}
|
||||
@@ -38,7 +38,11 @@ impl<'a> Get for MemDbTxn<'a> {
|
||||
if self.2.contains(key.as_ref()) {
|
||||
return None;
|
||||
}
|
||||
self.1.get(key.as_ref()).cloned().or(self.0 .0.read().unwrap().get(key.as_ref()).cloned())
|
||||
self
|
||||
.1
|
||||
.get(key.as_ref())
|
||||
.cloned()
|
||||
.or_else(|| self.0 .0.read().unwrap().get(key.as_ref()).cloned())
|
||||
}
|
||||
}
|
||||
impl<'a> DbTxn for MemDbTxn<'a> {
|
||||
|
||||
@@ -53,10 +53,7 @@ mod shims {
|
||||
|
||||
impl Read for &[u8] {
|
||||
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
|
||||
let mut read = buf.len();
|
||||
if self.len() < buf.len() {
|
||||
read = self.len();
|
||||
}
|
||||
let read = buf.len().min(self.len());
|
||||
buf[.. read].copy_from_slice(&self[.. read]);
|
||||
*self = &self[read ..];
|
||||
Ok(read)
|
||||
|
||||
@@ -2,33 +2,12 @@
|
||||
#![doc = include_str!("../README.md")]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[allow(unused_imports)]
|
||||
#[doc(hidden)]
|
||||
#[macro_use]
|
||||
pub extern crate alloc;
|
||||
|
||||
pub mod sync;
|
||||
pub mod collections;
|
||||
pub mod io;
|
||||
|
||||
pub mod vec {
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use alloc::vec::*;
|
||||
#[cfg(feature = "std")]
|
||||
pub use std::vec::*;
|
||||
}
|
||||
|
||||
pub mod str {
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use alloc::str::*;
|
||||
#[cfg(feature = "std")]
|
||||
pub use std::str::*;
|
||||
}
|
||||
|
||||
pub mod string {
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use alloc::string::*;
|
||||
#[cfg(feature = "std")]
|
||||
pub use std::string::*;
|
||||
}
|
||||
pub use alloc::vec;
|
||||
pub use alloc::str;
|
||||
pub use alloc::string;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
pub use core::sync::*;
|
||||
pub use alloc::sync::*;
|
||||
|
||||
mod mutex_shim {
|
||||
#[cfg(feature = "std")]
|
||||
@@ -57,7 +58,7 @@ mod oncelock_shim {
|
||||
let mut lock = self.0.lock();
|
||||
if !*lock {
|
||||
unsafe {
|
||||
(core::ptr::addr_of!(self.1) as *mut Option<_>).write_unaligned(Some(f()));
|
||||
core::ptr::addr_of!(self.1).cast_mut().write_unaligned(Some(f()));
|
||||
}
|
||||
}
|
||||
*lock = true;
|
||||
|
||||
Reference in New Issue
Block a user