expand_products

Function expand_products 

Source
pub fn expand_products(input: TokenStream, mode: ScopeMode) -> TokenStream
Expand description

Expands a product syntax into a TokenStream.

§Examples

§Complete expansion


let input = quote! {
    impl Foo for $((This)(That)) { }
};

let output = expand_products(input, ScopeMode::Expand);
assert_eq!(
    output.to_string(),
    "impl Foo for This { } \
     impl Foo for That { }");

§Sub-expand


let input = quote! {
    let toplevel = thing ;
    ${ impl Foo for $((This)(That)) { } }
    ${ impl Bar for $((This)(That)) { } }
};

let output = expand_products(input, ScopeMode::SubExpand);
assert_eq!(
    output.to_string(),
    "let toplevel = thing ; \
     impl Foo for This { } \
     impl Foo for That { } \
     impl Bar for This { } \
     impl Bar for That { }"
);

§Auto-brace-semi


let input = quote! {
    impl Foo for $((This)(That)) { }
    impl Bar for $((This)(That)) { }
};

let output = expand_products(input, ScopeMode::AutoBraceSemi);
assert_eq!(
    output.to_string(),
    "impl Foo for This { } \
     impl Foo for That { } \
     impl Bar for This { } \
     impl Bar for That { }"
);