diff --git a/src/lib.rs b/src/lib.rs index 0786ec7..dc28208 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -347,7 +347,10 @@ impl ContiguousMemoryStorage { } #[cfg(feature = "debug")] -impl core::fmt::Debug for ContiguousMemoryStorage { +impl core::fmt::Debug for ContiguousMemoryStorage +where + Impl::StorageState: core::fmt::Debug, +{ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_struct("ContiguousMemoryStorage") .field("inner", &self.inner) diff --git a/src/tracker.rs b/src/tracker.rs index fcd40ab..cac31c8 100644 --- a/src/tracker.rs +++ b/src/tracker.rs @@ -3,23 +3,19 @@ use core::alloc::Layout; #[cfg(any(not(feature = "std")))] -use crate::types::*; +use crate::types::Vec; use crate::{error::ContiguousMemoryError, range::ByteRange}; /// A structure that keeps track of unused regions of memory within provided /// bounds. #[derive(Clone)] -#[cfg_attr(feature = "debug", derive(Debug))] pub struct AllocationTracker { size: usize, unused: Vec, } + impl AllocationTracker { /// Constructs a new `AllocationTracker` of the provided `size`. - /// - /// # Arguments - /// - /// * `size` - The total size of the memory region that will be tracked. pub fn new(size: usize) -> Self { let mut initial = Vec::new(); initial.push(ByteRange(0, size)); @@ -230,6 +226,16 @@ impl AllocationTracker { } } +#[cfg(feature = "debug")] +impl core::fmt::Debug for AllocationTracker { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("AllocationTracker") + .field("size", &self.size) + .field("unused", &self.unused) + .finish() + } +} + #[cfg(test)] mod tests { use super::*;