From d3e7f32a30dee9202f242f35b43e5f3d40429175 Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Mon, 18 Nov 2019 15:47:45 +0000 Subject: [PATCH] Macro optimization to reduce compilation times --- src/utils.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index 13dbe37..49e3d99 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -221,6 +221,11 @@ macro_rules! extension_trait { $(#[cfg(feature = "docs")] $imp)* }; + // Optimization: expand `$head` eagerly before starting a new method definition. + (@ext ($($head:tt)*) #[doc = $d:literal] $($tail:tt)*) => { + $($head)* extension_trait!(@ext (#[doc = $d]) $($tail)*); + }; + // Parse the return type in an extension method. (@doc ($($head:tt)*) -> impl Future $(+ $lt:lifetime)? [$f:ty] $($tail:tt)*) => { extension_trait!(@doc ($($head)* -> owned::ImplFuture<$out>) $($tail)*);