15 unstable releases (3 breaking)

0.4.0 Oct 8, 2023
0.3.0 Oct 2, 2023
0.2.19 Sep 30, 2023
0.1.0 Sep 26, 2023

#1476 in Procedural macros

Download history 5/week @ 2024-02-19 11/week @ 2024-02-26 4/week @ 2024-03-11 207/week @ 2024-04-01

211 downloads per month
Used in chitey

MIT license

28KB
542 lines

メモ

マクロ適用後

cargo install cargo-expand cargo expand

fn main() {
    let body = async {
        {
            ::std::io::_print(format_args!("Hello, world!\n"));
        };
    };
    #[allow(clippy::expect_used, clippy::diverging_sub_expression)]
    {
        return tokio::runtime::Builder::new_multi_thread()
            .enable_all()
            .build()
            .expect("Failed building the Runtime")
            .block_on(body);
    }
}
#[allow(non_camel_case_types, missing_docs)]
pub struct greet;
impl ::chitey::HttpServiceFactory for greet {
    fn register(&self) -> ::chitey::Resource {
        async fn greet(name: String) -> Responder {
            {
                ::std::io::_print(format_args!("Hello {0}!\n", name));
            };
            let builder = Response::builder();
            let ret = Bytes::copy_from_slice(b"source");
            Ok((builder, ret))
        }
        let __resource = ::chitey::Resource::new("/hello/{name}").regist(greet);
        return __resource;
    }
}
#[allow(non_camel_case_types, missing_docs)]
pub struct doubb;
impl ::chitey::HttpServiceFactory for doubb {
    fn register(&self) -> ::chitey::Resource {
        async fn doubb((name, id): (u32, String)) -> Responder {
            {
                let res = ::alloc::fmt::format(
                    format_args!("Hello {0}! id:{1}", name, id),
                );
                res
            };
            let builder = Response::builder();
            let ret = Bytes::copy_from_slice(b"source");
            Ok((builder, ret))
        }
        let __resource = ::chitey::Resource::new("/{id}/{name}").regist(doubb);
        return __resource;
    }
}
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
use actix_web::{get, web, App, HttpServer, Responder};
#[allow(non_camel_case_types, missing_docs)]
pub struct greet;
impl ::actix_web::dev::HttpServiceFactory for greet {
    fn register(self, __config: &mut actix_web::dev::AppService) {
        async fn greet(req: web::Path<(u32, String)>) -> impl Responder {
            let (name, id) = req.to_owned();
            {
                let res = ::alloc::fmt::format(
                    format_args!("Hello {0}! id:{1}", name, id),
                );
                res
            }
        }
        let __resource = ::actix_web::Resource::new("/{id}/{name}")
            .name("greet")
            .guard(::actix_web::guard::Get())
            .to(greet);
        ::actix_web::dev::HttpServiceFactory::register(__resource, __config);
    }
}
fn main() -> std::io::Result<()> {
    <::actix_web::rt::System>::new()
        .block_on(async move {
            {
                HttpServer::new(|| { App::new().service(greet) })
                    .bind("127.0.0.1:8080")?
                    .run()
                    .await
            }
        })
}

Dependencies

~305–750KB
~18K SLoC