I want to start Rocket in a module out of main()
, thus can simplify main()
but I failed. I modified the Quicktart from rocket
The code:
mod myRocket {
#![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
#[get("/")]
fn index() -> &'static str {
"Hello, world!"
}
pub fn startup() {
rocket::ignite().mount("/", routes![index]).launch();
}
}
fn main() {
myRocket::startup();
}
The error:
error: cannot find macro `routes!` in this scope
--> src\main.rs:12:37
|
12 | rocket::ignite().mount("/", routes![index]).launch();
|
I don't know how to fix it.