From 8f724ad767dd8fe6cf888c9ac31d15cd4740d861 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 13 May 2022 10:46:16 +0100 Subject: [PATCH] impl_standard_builder: Better comments explaining the parser --- crates/tor-config/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/tor-config/src/lib.rs b/crates/tor-config/src/lib.rs index c3b1309c1..08b4d6f2c 100644 --- a/crates/tor-config/src/lib.rs +++ b/crates/tor-config/src/lib.rs @@ -138,20 +138,26 @@ impl Reconfigure { /// * a test that the `Builder` can be deserialized from an empty [`config::Config`], /// and then built, and that the result is the same as the ordinary default. // -// The implementation munches fake "trait bounds" off the RHS. +// The implementation munches fake "trait bounds" (`: !Deserialie + !Wombat ...`) off the RHS. // We're going to add at least one more option. #[macro_export] macro_rules! impl_standard_builder { + // Convert the input into the "being processed format": { $Config:ty $(: $($options:tt)* )? } => { $crate::impl_standard_builder!{ + // ^Being processed format: @ ( try_deserialize ) $Config : $( $( $options )* )? + // ~~~~~~~~~~~~~~~ ^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + // present iff not !Deserialize type always present options yet to be parsed } }; + // If !Deserialize is the next option, implement it by making $try_deserialize absent { @ ( $($try_deserialize:ident)? ) $Config:ty : $(+)? !Deserialize $( $options:tt )* } => { $crate::impl_standard_builder!{ @ ( ) $Config : $( $options )* } }; + // Having parsed all options, produce output: { @ ( $($try_deserialize:ident)? ) $Config:ty : $(+)? } => { $crate::paste!{