From d5f67381aa4d0d51a11a1bd4e81cfc6d3c3ec860 Mon Sep 17 00:00:00 2001 From: Ofek Shaltiel Date: Mon, 19 Aug 2024 15:59:40 +0300 Subject: [PATCH] remove option interface for list and dequeue iterations --- src/typed.rs | 18 ++++++++---------- tests/test_lists.rs | 8 ++++---- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/typed.rs b/src/typed.rs index f6aa79a..8320a7b 100644 --- a/src/typed.rs +++ b/src/typed.rs @@ -395,7 +395,7 @@ where pub fn iter<'a, Q: ?Sized + Encode>( &'a self, list_key: &Q, - ) -> impl Iterator>> + 'a + ) -> impl Iterator> + 'a where L: Borrow, { @@ -405,7 +405,7 @@ where Ok((k, v)) => { let key = from_bytes::(&k)?; let val = from_bytes::(&v)?; - Ok(Some((key, val))) + Ok((key, val)) } }) } @@ -414,7 +414,7 @@ where pub fn iter_backwards<'a, Q: ?Sized + Encode>( &'a self, list_key: &Q, - ) -> impl Iterator>> + 'a + ) -> impl Iterator> + 'a where L: Borrow, { @@ -426,7 +426,7 @@ where Ok((k, v)) => { let key = from_bytes::(&k)?; let val = from_bytes::(&v)?; - Ok(Some((key, val))) + Ok((key, val)) } }) } @@ -611,14 +611,13 @@ where pub fn iter<'a, Q: ?Sized + Encode>( &'a self, list_key: &Q, - ) -> impl Iterator>> + 'a + ) -> impl Iterator> + 'a where L: Borrow, { self.list.iter(list_key).map(|res| match res { Err(e) => Err(e), - Ok(None) => Ok(None), - Ok(Some((_, v))) => Ok(Some(v)), + Ok((_, v)) => Ok(v), }) } @@ -626,14 +625,13 @@ where pub fn iter_backwards<'a, Q: ?Sized + Encode>( &'a self, list_key: &Q, - ) -> impl Iterator>> + 'a + ) -> impl Iterator> + 'a where L: Borrow, { self.list.iter_backwards(list_key).map(|res| match res { Err(e) => Err(e), - Ok(None) => Ok(None), - Ok(Some((_, v))) => Ok(Some(v)), + Ok((_, v)) => Ok(v), }) } } diff --git a/tests/test_lists.rs b/tests/test_lists.rs index 7289b3b..77f48c7 100644 --- a/tests/test_lists.rs +++ b/tests/test_lists.rs @@ -107,7 +107,7 @@ fn test_typed_lists() -> Result<()> { let items = typed .iter("texas") - .map(|res| res.unwrap().unwrap().1) + .map(|res| res.unwrap().1) .collect::>(); assert_eq!(items, vec![2005, 2009, 2008]); @@ -313,14 +313,14 @@ fn test_typed_queue() -> Result<()> { let items = queue .iter("orders") - .map(|res| res.unwrap().unwrap()) + .map(|res| res.unwrap()) .collect::>(); assert_eq!(items, vec![105, 104, 103, 100, 101, 102]); let items = queue .iter_backwards("orders") - .map(|res| res.unwrap().unwrap()) + .map(|res| res.unwrap()) .collect::>(); assert_eq!(items, vec![102, 101, 100, 103, 104, 105]); @@ -414,7 +414,7 @@ fn test_typed_promote() -> Result<()> { let items = || { typed .iter("mylist") - .map(|res| res.unwrap().unwrap().0) + .map(|res| res.unwrap().0) .collect::>() };