Enum texcraft_stdext::collections::groupingmap::Item
source · pub enum Item<T> {
BeginGroup,
Value(T),
}
Expand description
The item for the IterAll iterator.
Variants§
Implementations§
source§impl<T> Item<T>
impl<T> Item<T>
sourcepub fn adapt_map<B, F: FnMut(T) -> B>(f: F) -> impl FnMut(Item<T>) -> Item<B>
pub fn adapt_map<B, F: FnMut(T) -> B>(f: F) -> impl FnMut(Item<T>) -> Item<B>
Adapt a lambda to use in Iterator::map for iterators over this item.
When iterating over items of this type, one almost always wants to keep
Item::BeginGroup constant and apply a transformation to the Item::Value variant.
This adaptor function helps with this by converting a lambda that operates on T
to a lambda that operates on Item<T>
.
let start: Vec<Item<usize>> = vec![
Item::Value(1),
Item::BeginGroup,
Item::Value(2),
];
let end: Vec<Item<usize>> = start.into_iter().map(Item::adapt_map(|i| { i *100 })).collect();
assert_eq![end, vec![
Item::Value(100),
Item::BeginGroup,
Item::Value(200),
]];
Trait Implementations§
source§impl<K: Eq + Hash + Clone, V, T: BackingContainer<K, V>> FromIterator<Item<(K, V)>> for GroupingContainer<K, V, T>
impl<K: Eq + Hash + Clone, V, T: BackingContainer<K, V>> FromIterator<Item<(K, V)>> for GroupingContainer<K, V, T>
source§impl<T: PartialEq> PartialEq<Item<T>> for Item<T>
impl<T: PartialEq> PartialEq<Item<T>> for Item<T>
impl<T: Eq> Eq for Item<T>
impl<T> StructuralEq for Item<T>
impl<T> StructuralPartialEq for Item<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Item<T>where T: RefUnwindSafe,
impl<T> Send for Item<T>where T: Send,
impl<T> Sync for Item<T>where T: Sync,
impl<T> Unpin for Item<T>where T: Unpin,
impl<T> UnwindSafe for Item<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more