impl_standard_builder: Better comments explaining the parser

This commit is contained in:
Ian Jackson 2022-05-13 10:46:16 +01:00
parent be5bc04c02
commit 8f724ad767
1 changed files with 7 additions and 1 deletions

View File

@ -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!{