#![doc(html_logo_url = "https://raw.githubusercontent.com/yasuo-ozu/template_quote/main/logo.png")]
#![doc = include_str!("../README.md")]
pub use template_quote_impl::quote;
pub use template_quote_impl::quote_configured;
pub use template_quote_impl::quote_spanned;
pub use quote::ToTokens;
#[doc(hidden)]
pub mod __private {
pub use crate::imp::ext;
}
mod imp {
pub mod ext {
use quote::ToTokens;
use std::collections::btree_set::{self, BTreeSet};
use std::slice;
pub trait RepIteratorExt: Iterator + Sized {
fn __template_quote_into_iter(self) -> (Self, bool) {
(self, true)
}
}
impl<T: Iterator> RepIteratorExt for T {}
pub trait RepToTokensExt {
fn __template_quote_into_iter(&self) -> (ToTokensRepeat<'_, Self>, bool) {
(ToTokensRepeat(self), false)
}
}
impl<T: ToTokens + ?Sized> RepToTokensExt for T {}
pub struct ToTokensRepeat<'a, T: ?Sized>(&'a T);
impl<'a, T: ?Sized> Iterator for ToTokensRepeat<'a, T> {
type Item = &'a T;
fn next(&mut self) -> Option<Self::Item> {
Some(self.0)
}
}
pub trait RepAsIteratorExt<'q> {
type Iter: Iterator;
fn __template_quote_into_iter(&'q self) -> (Self::Iter, bool);
}
impl<'q, T: RepAsIteratorExt<'q> + ?Sized> RepAsIteratorExt<'q> for &T {
type Iter = T::Iter;
fn __template_quote_into_iter(&'q self) -> (Self::Iter, bool) {
<T as RepAsIteratorExt>::__template_quote_into_iter(*self)
}
}
impl<'q, T: RepAsIteratorExt<'q> + ?Sized> RepAsIteratorExt<'q> for &mut T {
type Iter = T::Iter;
fn __template_quote_into_iter(&'q self) -> (Self::Iter, bool) {
<T as RepAsIteratorExt>::__template_quote_into_iter(*self)
}
}
impl<'q, T: 'q> RepAsIteratorExt<'q> for [T] {
type Iter = slice::Iter<'q, T>;
fn __template_quote_into_iter(&'q self) -> (Self::Iter, bool) {
(self.iter(), true)
}
}
impl<'q, T: 'q, const N: usize> RepAsIteratorExt<'q> for [T; N] {
type Iter = slice::Iter<'q, T>;
fn __template_quote_into_iter(&'q self) -> (Self::Iter, bool) {
(self.iter(), true)
}
}
impl<'q, T: 'q> RepAsIteratorExt<'q> for Vec<T> {
type Iter = slice::Iter<'q, T>;
fn __template_quote_into_iter(&'q self) -> (Self::Iter, bool) {
(self.iter(), true)
}
}
impl<'q, T: 'q> RepAsIteratorExt<'q> for BTreeSet<T> {
type Iter = btree_set::Iter<'q, T>;
fn __template_quote_into_iter(&'q self) -> (Self::Iter, bool) {
(self.iter(), true)
}
}
}
}