pub trait Repeat<T: Iterator>: Sealed<T> { }Expand description
Defines the behavior of types that can be interpolated inside repeating patterns (#(...)*).
§Which types do Repeat
Iterator<T>consumes the iterator, iterating through every element.Borrow<[T]>(includesVec,array, andslice) iterates with theslice::itermethod, thus not consuming the original data.ToTokens, interpolates the variable in every iteration.
§Which types do NOT Repeat
IntoIterator, to avoid ambiguity (Ex. “Which behavior would have been used forVec, which implements bothIntoIteratorandBorrow<[T]>?”; “Which behavior would have been used for [TokenStream], which implements bothIntoIteratorandToTokens?”). To use the iterator, you may callIntoIterator::into_iterexplicitly.- Ambiguous types that implement at least two of the
Repeattraits. In the very unlikely case this happens, disambiguate the type by wrapping it under some structure that only implements the trait you desire to use.
Implementations on Foreign Types§
impl<'a, T: 'a, S: Borrow<[T]>> Repeat<Iter<'a, T>> for &'a S
Types that implement Borrow<[T]> may be used in repeating patterns.
This includes, but is not necessarily limited to, Vec, array and slice.
They, will not be consumed. Instead slice::iter will be implicitly called.
impl<'a, T: ToTokens + 'a> Repeat<ToTokensRepeat<'a, T>> for &'a T
Types that implement ToTokens may be used in repeating patterns.
The variable will be interpolated in every iteration.