aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-03-07 23:28:45 +0100
committermetamuffin <metamuffin@disroot.org>2026-03-07 23:28:45 +0100
commit9d1e1772c02032f70b6db584dddae8fd06b490d6 (patch)
tree9d97b4d3e1252c4b99f30a19f339700eaab44c45 /common
parentd1b7691adb7c40bf21053d324fdac16c544cd536 (diff)
downloadjellything-9d1e1772c02032f70b6db584dddae8fd06b490d6.tar
jellything-9d1e1772c02032f70b6db584dddae8fd06b490d6.tar.bz2
jellything-9d1e1772c02032f70b6db584dddae8fd06b490d6.tar.zst
manual clippy
Diffstat (limited to 'common')
-rw-r--r--common/object/src/buffer.rs6
-rw-r--r--common/object/src/lib.rs10
-rw-r--r--common/object/src/tag.rs1
-rw-r--r--common/object/src/value.rs12
-rw-r--r--common/src/routes.rs2
5 files changed, 15 insertions, 16 deletions
diff --git a/common/object/src/buffer.rs b/common/object/src/buffer.rs
index 4d3af34..0de5d70 100644
--- a/common/object/src/buffer.rs
+++ b/common/object/src/buffer.rs
@@ -65,7 +65,7 @@ pub fn vec_to_ob(v: Vec<u32>) -> Box<Object> {
//? safe way to do this?
unsafe { std::mem::transmute(v.into_boxed_slice()) }
}
-pub const fn slice_to_ob<'a>(v: &'a [u32]) -> &'a Object {
+pub const fn slice_to_ob(v: &[u32]) -> &Object {
//? safe way to do this?
unsafe { std::mem::transmute(v) }
}
@@ -73,7 +73,7 @@ pub const fn slice_to_ob<'a>(v: &'a [u32]) -> &'a Object {
#[inline]
pub(super) fn pad_vec(temp: &mut Vec<u8>) -> u32 {
let mut pad = 0;
- while temp.len() % 4 != 0 {
+ while !temp.len().is_multiple_of(4) {
pad += 1;
temp.push(0);
}
@@ -96,7 +96,7 @@ pub fn slice_u8_to_u32<'a>(value: &'a [u8]) -> Cow<'a, [u32]> {
trace!("encountered unalined slice");
Cow::Owned(
value
- .into_iter()
+ .iter()
.copied()
.array_chunks()
.map(u32::from_ne_bytes)
diff --git a/common/object/src/lib.rs b/common/object/src/lib.rs
index 3790730..aadd306 100644
--- a/common/object/src/lib.rs
+++ b/common/object/src/lib.rs
@@ -33,7 +33,7 @@ impl ToOwned for Object {
}
}
-pub const EMPTY: &'static Object = slice_to_ob(&[0]);
+pub const EMPTY: &Object = slice_to_ob(&[0]);
impl Object {
#[inline]
@@ -92,7 +92,7 @@ impl Object {
let padding = start_raw & 0b11;
u32_len * 4 - padding
}
- fn get_aligned<'a>(&'a self, index: usize) -> Option<&'a [u32]> {
+ fn get_aligned(&self, index: usize) -> Option<&[u32]> {
let start_raw = self.offsets()[index];
let end_raw = self
.offsets()
@@ -106,7 +106,7 @@ impl Object {
Some(&self.values()[start as usize..end as usize])
}
- fn get_unaligned<'a>(&'a self, index: usize) -> Option<&'a [u8]> {
+ fn get_unaligned(&self, index: usize) -> Option<&[u8]> {
let start_raw = self.offsets()[index];
let end_raw = self
.offsets()
@@ -188,7 +188,7 @@ impl Object {
for val in values {
if new_vals.iter().all(|rhs| rhs.get(ident) != val.get(ident)) {
any_new = true;
- new_vals.push(&val);
+ new_vals.push(val);
}
}
if any_new {
@@ -286,7 +286,7 @@ impl Iterator for KeysIter<'_> {
type Item = Tag;
fn next(&mut self) -> Option<Self::Item> {
if self.index >= self.object.tags().len() {
- return None;
+ None
} else {
self.index += 1;
Some(Tag(self.object.tags()[self.index - 1]))
diff --git a/common/object/src/tag.rs b/common/object/src/tag.rs
index c09af27..c937d43 100644
--- a/common/object/src/tag.rs
+++ b/common/object/src/tag.rs
@@ -34,6 +34,7 @@ impl<T: ?Sized> Display for TypedTag<T> {
self.0.fmt(f)
}
}
+#[allow(clippy::non_canonical_clone_impl)]
impl<T: ?Sized> Clone for TypedTag<T> {
fn clone(&self) -> Self {
Self(self.0, PhantomData)
diff --git a/common/object/src/value.rs b/common/object/src/value.rs
index 0a1ceb9..ace10fe 100644
--- a/common/object/src/value.rs
+++ b/common/object/src/value.rs
@@ -73,10 +73,7 @@ pub enum ValueType {
impl ValueType {
#[inline]
pub const fn is_aligned(self) -> bool {
- match self {
- ValueType::Binary | ValueType::String => false,
- _ => true,
- }
+ !matches!(self, ValueType::Binary | ValueType::String)
}
pub fn from_num(n: u32) -> Self {
match n {
@@ -180,7 +177,7 @@ impl<'a> ValueSer<'a> for &'a str {
impl ValueSer<'_> for u32 {
const TYPE: ValueType = ValueType::UInt;
fn load_aligned(buf: &[u32]) -> Option<Self> {
- buf.get(0).copied().map(u32::from_be)
+ buf.first().copied().map(u32::from_be)
}
fn store_aligned(&self, buf: &mut Vec<u32>) {
buf.push(self.to_be());
@@ -192,7 +189,7 @@ impl ValueSer<'_> for u32 {
impl ValueSer<'_> for Tag {
const TYPE: ValueType = ValueType::Tag;
fn load_aligned(buf: &[u32]) -> Option<Self> {
- buf.get(0).copied().map(u32::from_be).map(Tag)
+ buf.first().copied().map(u32::from_be).map(Tag)
}
fn store_aligned(&self, buf: &mut Vec<u32>) {
buf.push(self.0.to_be());
@@ -203,6 +200,7 @@ impl ValueSer<'_> for Tag {
}
impl ValueSer<'_> for u64 {
const TYPE: ValueType = ValueType::UInt;
+ #[allow(clippy::get_first)]
fn load_aligned(buf: &[u32]) -> Option<Self> {
let hi = u32::from_be(*buf.get(0)?) as u64;
let lo = u32::from_be(*buf.get(1)?) as u64;
@@ -259,7 +257,7 @@ impl<'a> ValueSer<'a> for &'a Object {
buf.extend(&self.0);
}
fn size(&self) -> usize {
- self.0.len() * size_of::<u32>()
+ std::mem::size_of_val(&self.0)
}
}
impl<'a> ValueSer<'a> for &'a [u8] {
diff --git a/common/src/routes.rs b/common/src/routes.rs
index 96f36e2..2880eeb 100644
--- a/common/src/routes.rs
+++ b/common/src/routes.rs
@@ -52,7 +52,7 @@ pub fn u_admin_log(warn_only: bool) -> String {
format!("/admin/log?warn_only={warn_only}")
}
pub fn u_admin_import() -> String {
- format!("/admin/import")
+ "/admin/import".to_string()
}
pub fn u_admin_import_post(incremental: bool) -> String {
format!("/admin/import?incremental={incremental}")