pub fn gen_mid(
    lang: &LanguageIdentifier,
    pluralrule_set: &[(PluralCategory, TokenStream)],
) -> TokenStream {
    let langid = gen_langid(lang);
    // make pluralrule_set iterable
    let mut iter = pluralrule_set.iter();

    let queued = iter.next();
    let rule_tokens = match queued {
        Some(pair) => {
            // instantiate tokenstream for folded match rules
            let mut tokens = create_return(pair.0, &pair.1);

            // add all tokens to token stream, separated by commas
            for pair in iter {
                let condition = create_return(pair.0, &pair.1);
                tokens = quote! { #tokens else #condition };
            }
            tokens = quote! { #tokens else { PluralCategory::OTHER } };
            tokens
        }
        None => quote! { { PluralCategory::OTHER }  },
    };

    // We can't use a closure here because closures can't get rvalue
    // promoted to statics. They may in the future.
    quote! {(
        #langid,
        |po| {
            #rule_tokens
        }
    )}
}
/// Generates the closures that comprise the majority of the generated rust code.
///
/// These statements are the expression representations of the CLDR plural rules.
Generates the closures that comprise the majority of the generated rust code.
These statements are the expression representations of the CLDR plural rules.
Generates the closures that comprise the majority of the generated rust code . These statements are the expression representations of the CLDR plural rules .
pub fn gen_mid(
    lang: &LanguageIdentifier,
    pluralrule_set: &[(PluralCategory, TokenStream)],
) -> TokenStream {
    let langid = gen_langid(lang);
    // make pluralrule_set iterable
    let mut iter = pluralrule_set.iter();
    let queued = iter.next();
    let rule_tokens = match queued {
        Some(pair) => {
            // instantiate tokenstream for folded match rules
            let mut tokens = create_return(pair.0, &pair.1);
            // add all tokens to token stream, separated by commas
            for pair in iter {
                let condition = create_return(pair.0, &pair.1);
                tokens = quote! { #tokens else #condition };
            }
            tokens = quote! { #tokens else { PluralCategory::OTHER } };
            tokens
        }
        None => quote! { { PluralCategory::OTHER }  },
    };
    // We can't use a closure here because closures can't get rvalue
    // promoted to statics. They may in the future.
    quote! {(
        #langid,
        |po| {
            #rule_tokens
        }
    )}
}
pub fn gen_mid ( lang : & LanguageIdentifier , pluralrule_set : & [ ( PluralCategory , TokenStream ) ] , ) -> TokenStream { let langid = gen_langid ( lang ) ; // make pluralrule_set iterable let mut iter = pluralrule_set . iter ( ) ; let queued = iter . next ( ) ; let rule_tokens = match queued { Some ( pair ) => { // instantiate tokenstream for folded match rules let mut tokens = create_return ( pair . 0 , & pair . 1 ) ; // add all tokens to token stream, separated by commas for pair in iter { let condition = create_return ( pair . 0 , & pair . 1 ) ; tokens = quote ! { tokens else condition } ; } tokens = quote ! { tokens else { PluralCategory OTHER } } ; tokens } None => quote ! { { PluralCategory OTHER } } , } ; // We can't use a closure here because closures can't get rvalue // promoted to statics. They may in the future. quote ! { ( langid po { rule_tokens } ) } }
Generates the closures that comprise the majority of the generated rust code.
Generates the closures that comprise the majority of the generated rust code .
lang
&LanguageIdentifier
pluralrule_set
&[(PluralCategory, TokenStream)]
lang
&LanguageIdentifier
pluralrule_set
&[(PluralCategory, TokenStream)]