diff options
Diffstat (limited to 'crates/core/src/hive/group.rs')
-rw-r--r-- | crates/core/src/hive/group.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/crates/core/src/hive/group.rs b/crates/core/src/hive/group.rs index 32d070e..9217897 100644 --- a/crates/core/src/hive/group.rs +++ b/crates/core/src/hive/group.rs @@ -1,4 +1,4 @@ -//! An implementation of the individual memory blocks that make up a [`Hive`]. +//! An implementation of the individual memory blocks that make up a hive. use core::{ mem::{self, ManuallyDrop}, @@ -27,6 +27,7 @@ where /// implementation. #[repr(C, packed)] #[derive(Copy, Clone)] +#[cfg_attr(feature = "core-fmt", derive(Debug))] pub struct FreeList<Sk> where Sk: skipfield::SkipfieldType, @@ -39,6 +40,7 @@ where } /// A doubly-linked `Group` of `T` with a skipfield type of `Sk`. +#[cfg_attr(feature = "core-fmt", derive(Debug))] pub struct Group<T, Sk> where Sk: skipfield::SkipfieldType, @@ -74,7 +76,7 @@ where /// Pointer to the previous [`Group`] with erased elements. pub previous_with_erasures: Option<NonNull<Group<T, Sk>>>, - /// Number assigned to this group in the [`Hive`]. + /// Number assigned to this group. pub number: usize, } @@ -98,7 +100,23 @@ const fn compute_element_allocation_size<T, Sk>() -> usize { } else { t_align } + } else if sk2_size > t_size { + sk2_size } else { - if sk2_size > t_size { sk2_size } else { t_size } + t_size + } +} + +#[cfg(all(test, feature = "core-error"))] +mod test { + use super::*; + + #[test] + fn validate_element_allocation_size() { + assert_eq!( + Group::<u32, u8>::ELEMENT_ALLOCATION_SIZE, + 4, + "element allocation size with T = u32, Sk = u8 is 4" + ); } } |