From 6986317a032bf417bc5f5f75c531bad9291d66e7 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Wed, 11 Oct 2023 14:13:26 +0200 Subject: [PATCH] Add iter() to owned slice (#1620) --- libafl_bolts/src/ownedref.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libafl_bolts/src/ownedref.rs b/libafl_bolts/src/ownedref.rs index 6157608843..fee5f7885b 100644 --- a/libafl_bolts/src/ownedref.rs +++ b/libafl_bolts/src/ownedref.rs @@ -286,6 +286,11 @@ impl<'a, T> OwnedSlice<'a, T> { } } } + + /// Returns an iterator over the slice. + pub fn iter(&self) -> Iter<'_, T> { + <&Self as IntoIterator>::into_iter(self) + } } impl<'a, 'it, T> IntoIterator for &'it OwnedSlice<'a, T> { @@ -509,6 +514,16 @@ impl<'a, T: 'a + Sized> OwnedMutSlice<'a, T> { } } } + + /// Returns an iterator over the slice. + pub fn iter(&self) -> Iter<'_, T> { + <&Self as IntoIterator>::into_iter(self) + } + + /// Returns a mutable iterator over the slice. + pub fn iter_mut(&mut self) -> IterMut<'_, T> { + <&mut Self as IntoIterator>::into_iter(self) + } } impl<'a, T: Sized> AsSlice for OwnedMutSlice<'a, T> {