fn write_for_token(token: &ShadowMatcherToken, naming_scheme: FieldType) -> TokenStream2 {
    match token {
        ShadowMatcherToken::Exact(lit) => {
            quote! {
                write!(buf, #lit).unwrap();
            }
        }
        ShadowMatcherToken::Capture(capture) => {
            match naming_scheme {
                FieldType::Named | FieldType::Unit => match &capture {
                    ShadowCaptureVariant::Named(name)
                    | ShadowCaptureVariant::ManyNamed(name)
                    | ShadowCaptureVariant::NumberedNamed { name, .. } => {
                        let name = Ident::new(&name, Span::call_site());
                        quote! {
                            state = state.or(#name.build_route_section(buf));
                        }
                    }
                },
                FieldType::Unnamed { index } => {
                    match &capture {
                        ShadowCaptureVariant::Named(_)
                        | ShadowCaptureVariant::ManyNamed(_)
                        | ShadowCaptureVariant::NumberedNamed { .. } => {
                            let name = unnamed_field_index_item(index);
                            // TODO this either needs to find type info from a ty passed in, or
                            // RouteInfo needs to be nixed.
                            quote! {
                                state = state.or(#name.build_route_section(&mut buf)); // TODO, this needs type information in order not to clobber the namespace. I don't want to have to import RouteInfo.
                            }
                        }
                    }
                }
            }
        }
        ShadowMatcherToken::End => quote!{}
    }
}
/// This assumes that the variant/struct has been destructured.
This assumes that the variant/struct has been destructured.
This assumes that the variant / struct has been destructured .
fn write_for_token(token: &ShadowMatcherToken, naming_scheme: FieldType) -> TokenStream2 {
    match token {
        ShadowMatcherToken::Exact(lit) => {
            quote! {
                write!(buf, #lit).unwrap();
            }
        }
        ShadowMatcherToken::Capture(capture) => {
            match naming_scheme {
                FieldType::Named | FieldType::Unit => match &capture {
                    ShadowCaptureVariant::Named(name)
                    | ShadowCaptureVariant::ManyNamed(name)
                    | ShadowCaptureVariant::NumberedNamed { name, .. } => {
                        let name = Ident::new(&name, Span::call_site());
                        quote! {
                            state = state.or(#name.build_route_section(buf));
                        }
                    }
                },
                FieldType::Unnamed { index } => {
                    match &capture {
                        ShadowCaptureVariant::Named(_)
                        | ShadowCaptureVariant::ManyNamed(_)
                        | ShadowCaptureVariant::NumberedNamed { .. } => {
                            let name = unnamed_field_index_item(index);
                            // TODO this either needs to find type info from a ty passed in, or
                            // RouteInfo needs to be nixed.
                            quote! {
                                state = state.or(#name.build_route_section(&mut buf)); // TODO, this needs type information in order not to clobber the namespace. I don't want to have to import RouteInfo.
                            }
                        }
                    }
                }
            }
        }
        ShadowMatcherToken::End => quote!{}
    }
}
fn write_for_token ( token : & ShadowMatcherToken , naming_scheme : FieldType ) -> TokenStream2 { match token { ShadowMatcherToken :: Exact ( lit ) => { quote ! { write ( buf lit ) unwrap ( ) } } ShadowMatcherToken :: Capture ( capture ) => { match naming_scheme { FieldType :: Named | FieldType :: Unit => match & capture { ShadowCaptureVariant :: Named ( name ) | ShadowCaptureVariant :: ManyNamed ( name ) | ShadowCaptureVariant :: NumberedNamed { name , .. } => { let name = Ident :: new ( & name , Span :: call_site ( ) ) ; quote ! { state state or ( name build_route_section ( buf ) ) } } } , FieldType :: Unnamed { index } => { match & capture { ShadowCaptureVariant :: Named ( _ ) | ShadowCaptureVariant :: ManyNamed ( _ ) | ShadowCaptureVariant :: NumberedNamed { .. } => { let name = unnamed_field_index_item ( index ) ; // TODO this either needs to find type info from a ty passed in, or // RouteInfo needs to be nixed. quote ! { state state or ( name build_route_section ( mut buf ) ) // TODO, this needs type information in order not to clobber the namespace. I don't want to have to import RouteInfo. } } } } } } ShadowMatcherToken :: End => quote ! { } } }
This assumes that the variant/struct has been destructured.
This assumes that the variant / struct has been destructured .
token
&ShadowMatcherToken
naming_scheme
FieldType
token
&ShadowMatcherToken
naming_scheme
FieldType