From 05591421d0c2f70e8b3bfefd216599f9bcac9287 Mon Sep 17 00:00:00 2001 From: Aatif Syed Date: Tue, 4 Nov 2025 09:50:40 +0000 Subject: [PATCH 1/4] mark: aatifsyed/peeking-next-btree From da8dee158d032a294704e7dc961de3885a7def4d Mon Sep 17 00:00:00 2001 From: Aatif Syed Date: Tue, 4 Nov 2025 09:57:24 +0000 Subject: [PATCH 2/4] feat: impl PeekingNext for std::collections::* --- src/peeking_take_while.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/peeking_take_while.rs b/src/peeking_take_while.rs index e828b717d..dfe561a62 100644 --- a/src/peeking_take_while.rs +++ b/src/peeking_take_while.rs @@ -242,11 +242,30 @@ peeking_next_by_clone! { ['a] ::std::str::Bytes<'a> } peeking_next_by_clone! { ['a, T] ::std::option::Iter<'a, T> } peeking_next_by_clone! { ['a, T] ::std::result::Iter<'a, T> } peeking_next_by_clone! { [T] ::std::iter::Empty } + #[cfg(feature = "use_alloc")] peeking_next_by_clone! { ['a, T] alloc::collections::linked_list::Iter<'a, T> } #[cfg(feature = "use_alloc")] peeking_next_by_clone! { ['a, T] alloc::collections::vec_deque::Iter<'a, T> } +#[cfg(feature = "use_alloc")] +peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Iter<'a, K, V> } +#[cfg(feature = "use_alloc")] +peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Keys<'a, K, V> } +#[cfg(feature = "use_alloc")] +peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Values<'a, K, V> } + +#[cfg(feature = "use_alloc")] +peeking_next_by_clone! { ['a, T] alloc::collections::btree_set::Iter<'a, T> } +#[cfg(feature = "use_alloc")] +peeking_next_by_clone! { ['a, T] alloc::collections::binary_heap::Iter<'a, T> } + +peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Iter<'a, K, V> } +peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Keys<'a, K, V> } +peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Values<'a, K, V> } + +peeking_next_by_clone! { ['a, T] std::collections::hash_set::Iter<'a, T> } + // cloning a Rev has no extra overhead; peekable and put backs are never DEI. peeking_next_by_clone! { [I: Clone + PeekingNext + DoubleEndedIterator] ::std::iter::Rev } From b51f0762c4c6ec910fefd700babb1d7865f57c88 Mon Sep 17 00:00:00 2001 From: Aatif Syed Date: Tue, 4 Nov 2025 10:27:11 +0000 Subject: [PATCH 3/4] fix: feature gating --- src/peeking_take_while.rs | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/peeking_take_while.rs b/src/peeking_take_while.rs index dfe561a62..4f61fa6ca 100644 --- a/src/peeking_take_while.rs +++ b/src/peeking_take_while.rs @@ -244,27 +244,26 @@ peeking_next_by_clone! { ['a, T] ::std::result::Iter<'a, T> } peeking_next_by_clone! { [T] ::std::iter::Empty } #[cfg(feature = "use_alloc")] -peeking_next_by_clone! { ['a, T] alloc::collections::linked_list::Iter<'a, T> } -#[cfg(feature = "use_alloc")] -peeking_next_by_clone! { ['a, T] alloc::collections::vec_deque::Iter<'a, T> } +const _: () = { + peeking_next_by_clone! { ['a, T] alloc::collections::linked_list::Iter<'a, T> } + peeking_next_by_clone! { ['a, T] alloc::collections::vec_deque::Iter<'a, T> } -#[cfg(feature = "use_alloc")] -peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Iter<'a, K, V> } -#[cfg(feature = "use_alloc")] -peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Keys<'a, K, V> } -#[cfg(feature = "use_alloc")] -peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Values<'a, K, V> } + peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Iter<'a, K, V> } + peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Keys<'a, K, V> } + peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Values<'a, K, V> } -#[cfg(feature = "use_alloc")] -peeking_next_by_clone! { ['a, T] alloc::collections::btree_set::Iter<'a, T> } -#[cfg(feature = "use_alloc")] -peeking_next_by_clone! { ['a, T] alloc::collections::binary_heap::Iter<'a, T> } + peeking_next_by_clone! { ['a, T] alloc::collections::btree_set::Iter<'a, T> } + peeking_next_by_clone! { ['a, T] alloc::collections::binary_heap::Iter<'a, T> } +}; -peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Iter<'a, K, V> } -peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Keys<'a, K, V> } -peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Values<'a, K, V> } +#[cfg(feature = "use_std")] +const _: () = { + peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Iter<'a, K, V> } + peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Keys<'a, K, V> } + peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Values<'a, K, V> } -peeking_next_by_clone! { ['a, T] std::collections::hash_set::Iter<'a, T> } + peeking_next_by_clone! { ['a, T] std::collections::hash_set::Iter<'a, T> } +}; // cloning a Rev has no extra overhead; peekable and put backs are never DEI. peeking_next_by_clone! { [I: Clone + PeekingNext + DoubleEndedIterator] From 8c7e76148e8f19d8819e53c7a98c45b8e9c0b951 Mon Sep 17 00:00:00 2001 From: Aatif Syed Date: Tue, 4 Nov 2025 11:40:44 +0000 Subject: [PATCH 4/4] chore: feature gate style --- src/peeking_take_while.rs | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/peeking_take_while.rs b/src/peeking_take_while.rs index 4f61fa6ca..b74fa5807 100644 --- a/src/peeking_take_while.rs +++ b/src/peeking_take_while.rs @@ -244,26 +244,30 @@ peeking_next_by_clone! { ['a, T] ::std::result::Iter<'a, T> } peeking_next_by_clone! { [T] ::std::iter::Empty } #[cfg(feature = "use_alloc")] -const _: () = { - peeking_next_by_clone! { ['a, T] alloc::collections::linked_list::Iter<'a, T> } - peeking_next_by_clone! { ['a, T] alloc::collections::vec_deque::Iter<'a, T> } +peeking_next_by_clone! { ['a, T] alloc::collections::linked_list::Iter<'a, T> } +#[cfg(feature = "use_alloc")] +peeking_next_by_clone! { ['a, T] alloc::collections::vec_deque::Iter<'a, T> } - peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Iter<'a, K, V> } - peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Keys<'a, K, V> } - peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Values<'a, K, V> } +#[cfg(feature = "use_alloc")] +peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Iter<'a, K, V> } +#[cfg(feature = "use_alloc")] +peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Keys<'a, K, V> } +#[cfg(feature = "use_alloc")] +peeking_next_by_clone! { ['a, K, V] alloc::collections::btree_map::Values<'a, K, V> } - peeking_next_by_clone! { ['a, T] alloc::collections::btree_set::Iter<'a, T> } - peeking_next_by_clone! { ['a, T] alloc::collections::binary_heap::Iter<'a, T> } -}; +#[cfg(feature = "use_alloc")] +peeking_next_by_clone! { ['a, T] alloc::collections::btree_set::Iter<'a, T> } +#[cfg(feature = "use_alloc")] +peeking_next_by_clone! { ['a, T] alloc::collections::binary_heap::Iter<'a, T> } #[cfg(feature = "use_std")] -const _: () = { - peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Iter<'a, K, V> } - peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Keys<'a, K, V> } - peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Values<'a, K, V> } +peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Iter<'a, K, V> } +#[cfg(feature = "use_std")] +peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Keys<'a, K, V> } +#[cfg(feature = "use_std")] +peeking_next_by_clone! { ['a, K, V] std::collections::hash_map::Values<'a, K, V> } - peeking_next_by_clone! { ['a, T] std::collections::hash_set::Iter<'a, T> } -}; +peeking_next_by_clone! { ['a, T] std::collections::hash_set::Iter<'a, T> } // cloning a Rev has no extra overhead; peekable and put backs are never DEI. peeking_next_by_clone! { [I: Clone + PeekingNext + DoubleEndedIterator]