From 88ea4c61808934fc0f9fc0742c8b338e799046a0 Mon Sep 17 00:00:00 2001 From: Ivan Krivosheev Date: Mon, 5 Feb 2024 19:25:41 +0300 Subject: [PATCH 1/2] feat: Implemented MemoryBlockIterator for Box --- src/internals/iterator.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/internals/iterator.rs b/src/internals/iterator.rs index 1f31241..6725b6c 100644 --- a/src/internals/iterator.rs +++ b/src/internals/iterator.rs @@ -35,10 +35,32 @@ pub trait MemoryBlockIterator { fn next(&mut self) -> Option; } +impl MemoryBlockIterator for Box +where + T: MemoryBlockIterator, +{ + fn first(&mut self) -> Option { + (**self).first() + } + + fn next(&mut self) -> Option { + (**self).next() + } +} + pub trait MemoryBlockIteratorSized: MemoryBlockIterator { fn file_size(&mut self) -> u64; } +impl MemoryBlockIteratorSized for Box +where + T: MemoryBlockIteratorSized, +{ + fn file_size(&mut self) -> u64 { + (**self).file_size() + } +} + #[derive(Debug)] pub struct WrapperMemoryBlockIterator { iter: T, From 8d78f8c7fe7250485306817533efd97681e224cf Mon Sep 17 00:00:00 2001 From: Ivan Krivosheev Date: Tue, 6 Feb 2024 09:29:18 +0300 Subject: [PATCH 2/2] feat: Implemented Iterator for &mut T --- src/internals/iterator.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/internals/iterator.rs b/src/internals/iterator.rs index 6725b6c..2dc8ff8 100644 --- a/src/internals/iterator.rs +++ b/src/internals/iterator.rs @@ -48,6 +48,19 @@ where } } +impl MemoryBlockIterator for &mut T +where + T: MemoryBlockIterator, +{ + fn first(&mut self) -> Option { + (**self).first() + } + + fn next(&mut self) -> Option { + (**self).next() + } +} + pub trait MemoryBlockIteratorSized: MemoryBlockIterator { fn file_size(&mut self) -> u64; } @@ -61,6 +74,15 @@ where } } +impl MemoryBlockIteratorSized for &mut T +where + T: MemoryBlockIteratorSized, +{ + fn file_size(&mut self) -> u64 { + (**self).file_size() + } +} + #[derive(Debug)] pub struct WrapperMemoryBlockIterator { iter: T,