1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
//! THIS IS A NON-WORKING CONCEPT, FOR FUTURE DEVELOPMENT
// This is a fanciful example of future possibilities!
//
// Example that makes a self-cross-product out of an enum,
// (We only support unit enums without generics, for clarity.)
//
// This demonstrates use of the outer context facility.
define_derive_deftly!{
Squared =
// New expansions:
// ${outer_variant ...}
// ${outer_field ...}
// Expands ... in the context of an outer iteration.
// Can be nested to get an outer outer context.
$tvis enum $[$ttype Squared] {
${for variants {
${for variants {
$[ ${outer_variant $vname} $vname ],
}}
}}
}
}
#[derive(Deftly)]
#[derive_deftly(Squared)]
enum Greek {
Alpha,
Beta,
}
// Expands to:
enum GreekSquared {
AlphaAlpha,
AlphaBeta,
BetaAlpha,,
BetaBeta,
}
fn main(){
}
|