Rustc now allows many derives for packed structs

This commit is contained in:
bjorn3
2025-04-01 21:51:10 +02:00
parent dc507f7e2a
commit 22f759aa4f
4 changed files with 4 additions and 48 deletions
+1 -28
View File
@@ -172,6 +172,7 @@ impl Allocator {
}
#[repr(C, packed)]
#[derive(Clone, Copy, Default, Debug)]
pub struct AllocEntry {
/// The index of the first block this [`AllocEntry`] refers to
index: Le<u64>,
@@ -210,34 +211,6 @@ impl AllocEntry {
}
}
impl Clone for AllocEntry {
fn clone(&self) -> Self {
*self
}
}
impl Copy for AllocEntry {}
impl Default for AllocEntry {
fn default() -> Self {
Self {
index: 0.into(),
count: 0.into(),
}
}
}
impl fmt::Debug for AllocEntry {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let index = self.index();
let count = self.count();
f.debug_struct("AllocEntry")
.field("index", &index)
.field("count", &count)
.finish()
}
}
/// A node in the allocation chain.
#[repr(C, packed)]
pub struct AllocList {
+1 -6
View File
@@ -286,6 +286,7 @@ impl<T> fmt::Debug for BlockPtr<T> {
}
#[repr(C, packed)]
#[derive(Clone)]
pub struct BlockRaw([u8; BLOCK_SIZE as usize]);
unsafe impl BlockTrait for BlockRaw {
@@ -298,12 +299,6 @@ unsafe impl BlockTrait for BlockRaw {
}
}
impl Clone for BlockRaw {
fn clone(&self) -> Self {
Self(self.0)
}
}
impl ops::Deref for BlockRaw {
type Target = [u8];
fn deref(&self) -> &[u8] {
+1 -8
View File
@@ -4,6 +4,7 @@ use core::{mem, ops, slice, str};
use crate::{BlockLevel, BlockTrait, Node, TreePtr, DIR_ENTRY_MAX_LENGTH, RECORD_LEVEL};
#[repr(C, packed)]
#[derive(Clone, Copy)]
pub struct DirEntry {
node_ptr: TreePtr<Node>,
name: [u8; DIR_ENTRY_MAX_LENGTH],
@@ -38,14 +39,6 @@ impl DirEntry {
}
}
impl Clone for DirEntry {
fn clone(&self) -> Self {
*self
}
}
impl Copy for DirEntry {}
impl Default for DirEntry {
fn default() -> Self {
Self {
+1 -6
View File
@@ -4,6 +4,7 @@ use core::ops;
use crate::{BlockLevel, BlockTrait, RECORD_LEVEL};
//TODO: this is a box to prevent stack overflows
#[derive(Clone)]
pub struct RecordRaw(Box<[u8]>);
unsafe impl BlockTrait for RecordRaw {
@@ -16,12 +17,6 @@ unsafe impl BlockTrait for RecordRaw {
}
}
impl Clone for RecordRaw {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl ops::Deref for RecordRaw {
type Target = [u8];
fn deref(&self) -> &[u8] {