fn transform_method(method: &mut ImplItemMethod) -> ImplItemType {
    method.sig.asyncness = None;

    // get either the return type or ().
    let ret = match &method.sig.output {
        ReturnType::Default => quote!(()),
        ReturnType::Type(_, ret) => quote!(#ret),
    };

    // generate an identifier consisting of the method name to CamelCase with
    // Fut appended to it.
    let fut_name = snake_to_camel(&method.sig.ident.unraw().to_string()) + "Fut";
    let fut_name_ident = Ident::new(&fut_name, method.sig.ident.span());

    // generate the updated return signature.
    method.sig.output = parse_quote! {
        -> ::core::pin::Pin<Box<
                dyn ::core::future::Future<Output = #ret> + ::core::marker::Send
            >>
    };

    // transform the body of the method into Box::pin(async move { body }).
    let block = method.block.clone();
    method.block = parse_quote! [{
        Box::pin(async move
            #block
        )
    }];

    // generate and return type declaration for return type.
    let t: ImplItemType = parse_quote! {
        type #fut_name_ident = ::core::pin::Pin<Box<dyn ::core::future::Future<Output = #ret> + ::core::marker::Send>>;
    };

    t
}
/// Transforms an async function into a sync one, returning a type declaration
/// for the return type (a future).
Transforms an async function into a sync one, returning a type declaration
for the return type (a future).
Transforms an async function into a sync one returning a type declaration for the return type ( a future ) .
fn transform_method(method: &mut ImplItemMethod) -> ImplItemType {
    method.sig.asyncness = None;
    // get either the return type or ().
    let ret = match &method.sig.output {
        ReturnType::Default => quote!(()),
        ReturnType::Type(_, ret) => quote!(#ret),
    };
    // generate an identifier consisting of the method name to CamelCase with
    // Fut appended to it.
    let fut_name = snake_to_camel(&method.sig.ident.unraw().to_string()) + "Fut";
    let fut_name_ident = Ident::new(&fut_name, method.sig.ident.span());
    // generate the updated return signature.
    method.sig.output = parse_quote! {
        -> ::core::pin::Pin<Box<
                dyn ::core::future::Future<Output = #ret> + ::core::marker::Send
            >>
    };
    // transform the body of the method into Box::pin(async move { body }).
    let block = method.block.clone();
    method.block = parse_quote! [{
        Box::pin(async move
            #block
        )
    }];
    // generate and return type declaration for return type.
    let t: ImplItemType = parse_quote! {
        type #fut_name_ident = ::core::pin::Pin<Box<dyn ::core::future::Future<Output = #ret> + ::core::marker::Send>>;
    };
    t
}
fn transform_method ( method : & mut ImplItemMethod ) -> ImplItemType { method . sig . asyncness = None ; // get either the return type or (). let ret = match & method . sig . output { ReturnType :: Default => quote ! ( ( ) ) , ReturnType :: Type ( _ , ret ) => quote ! ( ret ) , } ; // generate an identifier consisting of the method name to CamelCase with // Fut appended to it. let fut_name = snake_to_camel ( & method . sig . ident . unraw ( ) . to_string ( ) ) + " " ; let fut_name_ident = Ident :: new ( & fut_name , method . sig . ident . span ( ) ) ; // generate the updated return signature. method . sig . output = parse_quote ! { core pin Pin Box dyn core future Future Output ret core marker Send } ; // transform the body of the method into Box::pin(async move { body }). let block = method . block . clone ( ) ; method . block = parse_quote ! [ { Box pin ( async move block ) } ] ; // generate and return type declaration for return type. let t : ImplItemType = parse_quote ! { type fut_name_ident core pin Pin Box dyn core future Future Output ret core marker Send } ; t }
Transforms an async function into a sync one, returning a type declaration
for the return type (a future).
Transforms an async function into a sync one returning a type declaration for the return type ( a future ) .
method
&mut ImplItemMethod
method
&mut ImplItemMethod