Remove `extension_trait`.

At this point, `extension_trait` is basically an expensive no-op. This
commit removes it. The next commit will adjust the indentation.
pull/1006/head
Nicholas Nethercote 3 years ago
parent 2dde8820fa
commit 1146c66f1b

@ -22,7 +22,6 @@ cfg_unstable_default! {
pub use core::future::Future as Future; pub use core::future::Future as Future;
extension_trait! {
#[doc = r#" #[doc = r#"
Extension methods for [`Future`]. Extension methods for [`Future`].
@ -45,7 +44,7 @@ extension_trait! {
/// ``` /// ```
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn delay(self, dur: Duration) -> [DelayFuture<Self>] fn delay(self, dur: Duration) -> DelayFuture<Self>
where where
Self: Sized, Self: Sized,
{ {
@ -70,7 +69,7 @@ extension_trait! {
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn flatten( fn flatten(
self, self,
) -> [FlattenFuture<Self, <Self::Output as IntoFuture>::Future>] ) -> FlattenFuture<Self, <Self::Output as IntoFuture>::Future>
where where
Self: Sized, Self: Sized,
<Self as Future>::Output: IntoFuture, <Self as Future>::Output: IntoFuture,
@ -112,7 +111,7 @@ extension_trait! {
fn race<F>( fn race<F>(
self, self,
other: F, other: F,
) -> [Race<Self, F>] ) -> Race<Self, F>
where where
Self: std::future::Future + Sized, Self: std::future::Future + Sized,
F: std::future::Future<Output = <Self as std::future::Future>::Output>, F: std::future::Future<Output = <Self as std::future::Future>::Output>,
@ -158,7 +157,7 @@ extension_trait! {
fn try_race<F, T, E>( fn try_race<F, T, E>(
self, self,
other: F other: F
) -> [TryRace<Self, F>] ) -> TryRace<Self, F>
where where
Self: std::future::Future<Output = Result<T, E>> + Sized, Self: std::future::Future<Output = Result<T, E>> + Sized,
F: std::future::Future<Output = <Self as std::future::Future>::Output>, F: std::future::Future<Output = <Self as std::future::Future>::Output>,
@ -195,7 +194,7 @@ extension_trait! {
fn join<F>( fn join<F>(
self, self,
other: F other: F
) -> [Join<Self, F>] ) -> Join<Self, F>
where where
Self: std::future::Future + Sized, Self: std::future::Future + Sized,
F: std::future::Future, F: std::future::Future,
@ -242,7 +241,7 @@ extension_trait! {
fn try_join<F, A, B, E>( fn try_join<F, A, B, E>(
self, self,
other: F other: F
) -> [TryJoin<Self, F>] ) -> TryJoin<Self, F>
where where
Self: std::future::Future<Output = Result<A, E>> + Sized, Self: std::future::Future<Output = Result<A, E>> + Sized,
F: std::future::Future<Output = Result<B, E>>, F: std::future::Future<Output = Result<B, E>>,
@ -278,13 +277,12 @@ extension_trait! {
"#] "#]
#[cfg(any(all(feature = "default", feature = "unstable"), feature = "docs"))] #[cfg(any(all(feature = "default", feature = "unstable"), feature = "docs"))]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn timeout(self, dur: Duration) -> [TimeoutFuture<Self>] fn timeout(self, dur: Duration) -> TimeoutFuture<Self>
where Self: Sized where Self: Sized
{ {
TimeoutFuture::new(self, dur) TimeoutFuture::new(self, dur)
} }
} }
}
impl<T: Future + ?Sized> FutureExt for T {} impl<T: Future + ?Sized> FutureExt for T {}

@ -17,7 +17,6 @@ use crate::task::{Context, Poll};
pub use futures_io::AsyncBufRead as BufRead; pub use futures_io::AsyncBufRead as BufRead;
extension_trait! {
#[doc = r#" #[doc = r#"
Extension methods for [`BufRead`]. Extension methods for [`BufRead`].
@ -78,7 +77,7 @@ extension_trait! {
&'a mut self, &'a mut self,
byte: u8, byte: u8,
buf: &'a mut Vec<u8>, buf: &'a mut Vec<u8>,
) -> [ReadUntilFuture<'a, Self>] ) -> ReadUntilFuture<'a, Self>
where where
Self: Unpin, Self: Unpin,
{ {
@ -131,7 +130,7 @@ extension_trait! {
fn read_line<'a>( fn read_line<'a>(
&'a mut self, &'a mut self,
buf: &'a mut String, buf: &'a mut String,
) -> [ReadLineFuture<'a, Self>] ) -> ReadLineFuture<'a, Self>
where where
Self: Unpin, Self: Unpin,
{ {
@ -237,7 +236,6 @@ extension_trait! {
} }
} }
} }
}
impl<T: BufRead + ?Sized> BufReadExt for T {} impl<T: BufRead + ?Sized> BufReadExt for T {}

@ -23,7 +23,6 @@ pub use take::Take;
pub use futures_io::AsyncRead as Read; pub use futures_io::AsyncRead as Read;
extension_trait! {
#[doc = r#" #[doc = r#"
Extension methods for [`Read`]. Extension methods for [`Read`].
@ -64,7 +63,7 @@ extension_trait! {
fn read<'a>( fn read<'a>(
&'a mut self, &'a mut self,
buf: &'a mut [u8], buf: &'a mut [u8],
) -> [ReadFuture<'a, Self>] ) -> ReadFuture<'a, Self>
where where
Self: Unpin Self: Unpin
{ {
@ -86,7 +85,7 @@ extension_trait! {
fn read_vectored<'a>( fn read_vectored<'a>(
&'a mut self, &'a mut self,
bufs: &'a mut [IoSliceMut<'a>], bufs: &'a mut [IoSliceMut<'a>],
) -> [ReadVectoredFuture<'a, Self>] ) -> ReadVectoredFuture<'a, Self>
where where
Self: Unpin, Self: Unpin,
{ {
@ -123,7 +122,7 @@ extension_trait! {
fn read_to_end<'a>( fn read_to_end<'a>(
&'a mut self, &'a mut self,
buf: &'a mut Vec<u8>, buf: &'a mut Vec<u8>,
) -> [ReadToEndFuture<'a, Self>] ) -> ReadToEndFuture<'a, Self>
where where
Self: Unpin, Self: Unpin,
{ {
@ -162,7 +161,7 @@ extension_trait! {
fn read_to_string<'a>( fn read_to_string<'a>(
&'a mut self, &'a mut self,
buf: &'a mut String, buf: &'a mut String,
) -> [ReadToStringFuture<'a, Self>] ) -> ReadToStringFuture<'a, Self>
where where
Self: Unpin, Self: Unpin,
{ {
@ -217,7 +216,7 @@ extension_trait! {
fn read_exact<'a>( fn read_exact<'a>(
&'a mut self, &'a mut self,
buf: &'a mut [u8], buf: &'a mut [u8],
) -> [ReadExactFuture<'a, Self>] ) -> ReadExactFuture<'a, Self>
where where
Self: Unpin, Self: Unpin,
{ {
@ -373,7 +372,6 @@ extension_trait! {
Chain { first: self, second: next, done_first: false } Chain { first: self, second: next, done_first: false }
} }
} }
}
impl<T: Read + ?Sized> ReadExt for T {} impl<T: Read + ?Sized> ReadExt for T {}

@ -6,7 +6,6 @@ use crate::io::SeekFrom;
pub use futures_io::AsyncSeek as Seek; pub use futures_io::AsyncSeek as Seek;
extension_trait! {
#[doc = r#" #[doc = r#"
Extension methods for [`Seek`]. Extension methods for [`Seek`].
@ -40,13 +39,12 @@ extension_trait! {
fn seek( fn seek(
&mut self, &mut self,
pos: SeekFrom, pos: SeekFrom,
) -> [SeekFuture<'_, Self>] ) -> SeekFuture<'_, Self>
where where
Self: Unpin, Self: Unpin,
{ {
SeekFuture { seeker: self, pos } SeekFuture { seeker: self, pos }
} }
} }
}
impl<T: Seek + ?Sized> SeekExt for T {} impl<T: Seek + ?Sized> SeekExt for T {}

@ -14,7 +14,6 @@ use crate::io::{self, IoSlice};
pub use futures_io::AsyncWrite as Write; pub use futures_io::AsyncWrite as Write;
extension_trait! {
#[doc = r#" #[doc = r#"
Extension methods for [`Write`]. Extension methods for [`Write`].
@ -49,7 +48,7 @@ extension_trait! {
fn write<'a>( fn write<'a>(
&'a mut self, &'a mut self,
buf: &'a [u8], buf: &'a [u8],
) -> [WriteFuture<'a, Self>] ) -> WriteFuture<'a, Self>
where where
Self: Unpin, Self: Unpin,
{ {
@ -75,7 +74,7 @@ extension_trait! {
# Ok(()) }) } # Ok(()) }) }
``` ```
"#] "#]
fn flush(&mut self) -> [FlushFuture<'_, Self>] fn flush(&mut self) -> FlushFuture<'_, Self>
where where
Self: Unpin, Self: Unpin,
{ {
@ -97,7 +96,7 @@ extension_trait! {
fn write_vectored<'a>( fn write_vectored<'a>(
&'a mut self, &'a mut self,
bufs: &'a [IoSlice<'a>], bufs: &'a [IoSlice<'a>],
) -> [WriteVectoredFuture<'a, Self>] ) -> WriteVectoredFuture<'a, Self>
where where
Self: Unpin, Self: Unpin,
{ {
@ -133,7 +132,7 @@ extension_trait! {
fn write_all<'a>( fn write_all<'a>(
&'a mut self, &'a mut self,
buf: &'a [u8], buf: &'a [u8],
) -> [WriteAllFuture<'a, Self>] ) -> WriteAllFuture<'a, Self>
where where
Self: Unpin, Self: Unpin,
{ {
@ -170,7 +169,7 @@ extension_trait! {
fn write_fmt<'a>( fn write_fmt<'a>(
&'a mut self, &'a mut self,
fmt: std::fmt::Arguments<'_>, fmt: std::fmt::Arguments<'_>,
) -> [WriteFmtFuture<'a, Self>] ) -> WriteFmtFuture<'a, Self>
where where
Self: Unpin, Self: Unpin,
{ {
@ -184,6 +183,5 @@ extension_trait! {
WriteFmtFuture { writer: self, res: Some(res), buffer: None, amt: 0 } WriteFmtFuture { writer: self, res: Some(res), buffer: None, amt: 0 }
} }
} }
}
impl<T: Write + ?Sized> WriteExt for T {} impl<T: Write + ?Sized> WriteExt for T {}

@ -145,7 +145,6 @@ cfg_unstable! {
pub use futures_core::stream::Stream as Stream; pub use futures_core::stream::Stream as Stream;
extension_trait! {
#[doc = r#" #[doc = r#"
Extension methods for [`Stream`]. Extension methods for [`Stream`].
@ -177,7 +176,7 @@ extension_trait! {
# }) } # }) }
``` ```
"#] "#]
fn next(&mut self) -> [NextFuture<'_, Self>] fn next(&mut self) -> NextFuture<'_, Self>
where where
Self: Unpin, Self: Unpin,
{ {
@ -629,7 +628,7 @@ extension_trait! {
"#] "#]
fn last( fn last(
self, self,
) -> [LastFuture<Self, Self::Item>] ) -> LastFuture<Self, Self::Item>
where where
Self: Sized, Self: Sized,
{ {
@ -839,7 +838,7 @@ extension_trait! {
fn min_by_key<B, F>( fn min_by_key<B, F>(
self, self,
key_by: F, key_by: F,
) -> [MinByKeyFuture<Self, Self::Item, F>] ) -> MinByKeyFuture<Self, Self::Item, F>
where where
Self: Sized, Self: Sized,
B: Ord, B: Ord,
@ -875,7 +874,7 @@ extension_trait! {
fn max_by_key<B, F>( fn max_by_key<B, F>(
self, self,
key_by: F, key_by: F,
) -> [MaxByKeyFuture<Self, Self::Item, F>] ) -> MaxByKeyFuture<Self, Self::Item, F>
where where
Self: Sized, Self: Sized,
B: Ord, B: Ord,
@ -914,7 +913,7 @@ extension_trait! {
fn min_by<F>( fn min_by<F>(
self, self,
compare: F, compare: F,
) -> [MinByFuture<Self, F, Self::Item>] ) -> MinByFuture<Self, F, Self::Item>
where where
Self: Sized, Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering, F: FnMut(&Self::Item, &Self::Item) -> Ordering,
@ -947,7 +946,7 @@ extension_trait! {
"#] "#]
fn max( fn max(
self, self,
) -> [MaxFuture<Self, Self::Item>] ) -> MaxFuture<Self, Self::Item>
where where
Self: Sized, Self: Sized,
Self::Item: Ord, Self::Item: Ord,
@ -980,7 +979,7 @@ extension_trait! {
"#] "#]
fn min( fn min(
self, self,
) -> [MinFuture<Self, Self::Item>] ) -> MinFuture<Self, Self::Item>
where where
Self: Sized, Self: Sized,
Self::Item: Ord, Self::Item: Ord,
@ -1018,7 +1017,7 @@ extension_trait! {
fn max_by<F>( fn max_by<F>(
self, self,
compare: F, compare: F,
) -> [MaxByFuture<Self, F, Self::Item>] ) -> MaxByFuture<Self, F, Self::Item>
where where
Self: Sized, Self: Sized,
F: FnMut(&Self::Item, &Self::Item) -> Ordering, F: FnMut(&Self::Item, &Self::Item) -> Ordering,
@ -1082,7 +1081,7 @@ extension_trait! {
fn nth( fn nth(
&mut self, &mut self,
n: usize, n: usize,
) -> [NthFuture<'_, Self>] ) -> NthFuture<'_, Self>
where where
Self: Unpin + Sized, Self: Unpin + Sized,
{ {
@ -1138,7 +1137,7 @@ extension_trait! {
fn all<F>( fn all<F>(
&mut self, &mut self,
f: F, f: F,
) -> [AllFuture<'_, Self, F, Self::Item>] ) -> AllFuture<'_, Self, F, Self::Item>
where where
Self: Unpin + Sized, Self: Unpin + Sized,
F: FnMut(Self::Item) -> bool, F: FnMut(Self::Item) -> bool,
@ -1187,7 +1186,7 @@ extension_trait! {
fn find<P>( fn find<P>(
&mut self, &mut self,
p: P, p: P,
) -> [FindFuture<'_, Self, P>] ) -> FindFuture<'_, Self, P>
where where
Self: Unpin + Sized, Self: Unpin + Sized,
P: FnMut(&Self::Item) -> bool, P: FnMut(&Self::Item) -> bool,
@ -1215,7 +1214,7 @@ extension_trait! {
fn find_map<F, B>( fn find_map<F, B>(
&mut self, &mut self,
f: F, f: F,
) -> [FindMapFuture<'_, Self, F>] ) -> FindMapFuture<'_, Self, F>
where where
Self: Unpin + Sized, Self: Unpin + Sized,
F: FnMut(Self::Item) -> Option<B>, F: FnMut(Self::Item) -> Option<B>,
@ -1249,7 +1248,7 @@ extension_trait! {
self, self,
init: B, init: B,
f: F, f: F,
) -> [FoldFuture<Self, F, B>] ) -> FoldFuture<Self, F, B>
where where
Self: Sized, Self: Sized,
F: FnMut(B, Self::Item) -> B, F: FnMut(B, Self::Item) -> B,
@ -1286,7 +1285,7 @@ extension_trait! {
fn partition<B, F>( fn partition<B, F>(
self, self,
f: F, f: F,
) -> [PartitionFuture<Self, F, B>] ) -> PartitionFuture<Self, F, B>
where where
Self: Sized, Self: Sized,
F: FnMut(&Self::Item) -> bool, F: FnMut(&Self::Item) -> bool,
@ -1322,7 +1321,7 @@ extension_trait! {
fn for_each<F>( fn for_each<F>(
self, self,
f: F, f: F,
) -> [ForEachFuture<Self, F>] ) -> ForEachFuture<Self, F>
where where
Self: Sized, Self: Sized,
F: FnMut(Self::Item), F: FnMut(Self::Item),
@ -1378,7 +1377,7 @@ extension_trait! {
fn any<F>( fn any<F>(
&mut self, &mut self,
f: F, f: F,
) -> [AnyFuture<'_, Self, F, Self::Item>] ) -> AnyFuture<'_, Self, F, Self::Item>
where where
Self: Unpin + Sized, Self: Unpin + Sized,
F: FnMut(Self::Item) -> bool, F: FnMut(Self::Item) -> bool,
@ -1614,7 +1613,7 @@ extension_trait! {
&mut self, &mut self,
init: T, init: T,
f: F, f: F,
) -> [TryFoldFuture<'_, Self, F, T>] ) -> TryFoldFuture<'_, Self, F, T>
where where
Self: Unpin + Sized, Self: Unpin + Sized,
F: FnMut(B, Self::Item) -> Result<T, E>, F: FnMut(B, Self::Item) -> Result<T, E>,
@ -1659,7 +1658,7 @@ extension_trait! {
fn try_for_each<F, E>( fn try_for_each<F, E>(
&mut self, &mut self,
f: F, f: F,
) -> [TryForEachFuture<'_, Self, F>] ) -> TryForEachFuture<'_, Self, F>
where where
Self: Unpin + Sized, Self: Unpin + Sized,
F: FnMut(Self::Item) -> Result<(), E>, F: FnMut(Self::Item) -> Result<(), E>,
@ -1741,7 +1740,7 @@ extension_trait! {
"#] "#]
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn unzip<A, B, FromA, FromB>(self) -> [UnzipFuture<Self, FromA, FromB>] fn unzip<A, B, FromA, FromB>(self) -> UnzipFuture<Self, FromA, FromB>
where where
FromA: Default + Extend<A>, FromA: Default + Extend<A>,
FromB: Default + Extend<B>, FromB: Default + Extend<B>,
@ -1805,7 +1804,7 @@ extension_trait! {
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn collect<'a, B>( fn collect<'a, B>(
self, self,
) -> [Pin<Box<dyn Future<Output = B> + 'a + Send>>] ) -> Pin<Box<dyn Future<Output = B> + 'a + Send>>
where where
Self: Sized + 'a + Send, Self: Sized + 'a + Send,
B: FromStream<Self::Item>, B: FromStream<Self::Item>,
@ -1879,7 +1878,7 @@ extension_trait! {
fn partial_cmp<S>( fn partial_cmp<S>(
self, self,
other: S other: S
) -> [PartialCmpFuture<Self, S>] ) -> PartialCmpFuture<Self, S>
where where
Self: Sized + Stream, Self: Sized + Stream,
S: Stream, S: Stream,
@ -1919,7 +1918,7 @@ extension_trait! {
fn position<P>( fn position<P>(
&mut self, &mut self,
predicate: P, predicate: P,
) -> [PositionFuture<'_, Self, P>] ) -> PositionFuture<'_, Self, P>
where where
Self: Unpin + Sized, Self: Unpin + Sized,
P: FnMut(Self::Item) -> bool, P: FnMut(Self::Item) -> bool,
@ -1957,7 +1956,7 @@ extension_trait! {
fn cmp<S>( fn cmp<S>(
self, self,
other: S other: S
) -> [CmpFuture<Self, S>] ) -> CmpFuture<Self, S>
where where
Self: Sized + Stream, Self: Sized + Stream,
S: Stream, S: Stream,
@ -1988,7 +1987,7 @@ extension_trait! {
"#] "#]
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn count(self) -> [CountFuture<Self>] fn count(self) -> CountFuture<Self>
where where
Self: Sized, Self: Sized,
{ {
@ -2023,7 +2022,7 @@ extension_trait! {
fn ne<S>( fn ne<S>(
self, self,
other: S other: S
) -> [NeFuture<Self, S>] ) -> NeFuture<Self, S>
where where
Self: Sized, Self: Sized,
S: Sized + Stream, S: Sized + Stream,
@ -2060,7 +2059,7 @@ extension_trait! {
fn ge<S>( fn ge<S>(
self, self,
other: S other: S
) -> [GeFuture<Self, S>] ) -> GeFuture<Self, S>
where where
Self: Sized + Stream, Self: Sized + Stream,
S: Stream, S: Stream,
@ -2097,7 +2096,7 @@ extension_trait! {
fn eq<S>( fn eq<S>(
self, self,
other: S other: S
) -> [EqFuture<Self, S>] ) -> EqFuture<Self, S>
where where
Self: Sized + Stream, Self: Sized + Stream,
S: Sized + Stream, S: Sized + Stream,
@ -2134,7 +2133,7 @@ extension_trait! {
fn gt<S>( fn gt<S>(
self, self,
other: S other: S
) -> [GtFuture<Self, S>] ) -> GtFuture<Self, S>
where where
Self: Sized + Stream, Self: Sized + Stream,
S: Stream, S: Stream,
@ -2171,7 +2170,7 @@ extension_trait! {
fn le<S>( fn le<S>(
self, self,
other: S other: S
) -> [LeFuture<Self, S>] ) -> LeFuture<Self, S>
where where
Self: Sized + Stream, Self: Sized + Stream,
S: Stream, S: Stream,
@ -2208,7 +2207,7 @@ extension_trait! {
fn lt<S>( fn lt<S>(
self, self,
other: S other: S
) -> [LtFuture<Self, S>] ) -> LtFuture<Self, S>
where where
Self: Sized + Stream, Self: Sized + Stream,
S: Stream, S: Stream,
@ -2252,7 +2251,7 @@ extension_trait! {
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn sum<'a, S>( fn sum<'a, S>(
self, self,
) -> [Pin<Box<dyn Future<Output = S> + 'a>>] ) -> Pin<Box<dyn Future<Output = S> + 'a>>
where where
Self: Sized + Stream<Item = S> + 'a, Self: Sized + Stream<Item = S> + 'a,
S: Sum<Self::Item>, S: Sum<Self::Item>,
@ -2298,7 +2297,7 @@ extension_trait! {
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn product<'a, P>( fn product<'a, P>(
self, self,
) -> [Pin<Box<dyn Future<Output = P> + 'a>>] ) -> Pin<Box<dyn Future<Output = P> + 'a>>
where where
Self: Sized + Stream<Item = P> + 'a, Self: Sized + Stream<Item = P> + 'a,
P: Product, P: Product,
@ -2306,7 +2305,6 @@ extension_trait! {
Product::product(self) Product::product(self)
} }
} }
}
impl<T: Stream + ?Sized> StreamExt for T {} impl<T: Stream + ?Sized> StreamExt for T {}

@ -233,41 +233,3 @@ macro_rules! cfg_default {
)* )*
} }
} }
/// Defines an extension trait for a base trait.
///
/// In generated docs, the base trait will contain methods from the extension trait. In actual
/// code, the base trait will be re-exported and the extension trait will be hidden. We then
/// re-export the extension trait from the prelude.
///
/// Inside invocations of this macro, we write a definitions that looks similar to the final
/// rendered docs, and the macro then generates all the boilerplate for us.
#[allow(unused_macros)]
#[doc(hidden)]
macro_rules! extension_trait {
(
#[doc = $doc_ext:tt]
pub trait $ext:ident: $name:ident {
$($body_ext:tt)*
}
) => {
// The extension trait that adds methods to any type implementing the base trait.
#[doc = $doc_ext]
pub trait $ext: $name {
extension_trait!(@ext [$($body_ext)*] -> []);
}
};
// Parse the return type in an extension method.
(@ext [-> [$f:ty] $($tail:tt)*] -> [$($accum:tt)*]) => {
extension_trait!(@ext [$($tail)*] -> [$($accum)* -> $f]);
};
// Parse a token.
(@ext [$token:tt $($tail:tt)*] -> [$($accum:tt)*]) => {
extension_trait!(@ext [$($tail)*] -> [$($accum)* $token]);
};
// Handle the end of the token list.
(@ext [] -> [$($accum:tt)*]) => { $($accum)* };
}

Loading…
Cancel
Save