proc_quote

Trait Repeat

Source
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

§Which types do NOT Repeat

  • IntoIterator, to avoid ambiguity (Ex. “Which behavior would have been used for Vec, which implements both IntoIterator and Borrow<[T]>?”; “Which behavior would have been used for [TokenStream], which implements both IntoIterator and ToTokens?”). To use the iterator, you may call IntoIterator::into_iter explicitly.
  • Ambiguous types that implement at least two of the Repeat traits. 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§

Source§

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.

Source§

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.

Implementors§

Source§

impl<T, I: Iterator<Item = T>> Repeat<I> for I

Types that implement Iterator may be used in repeating patterns.

They, will be consumed, so they can only be used in one pattern.