Cannot start rocket from module inside sub folder (src/<dir0> #2481
Unanswered
astrometrics
asked this question in
Questions
Replies: 1 comment 7 replies
-
Can you share your directory / file structure, and what code you've tried? Rocket can be started wherever you want in a handful of ways, depending on your needs. This is a minimal working example of starting in a sub-directory, however.
// main.rs
#[macro_use]
extern crate rocket;
mod subdir;
use crate::subdir::server;
fn main() {
server::main();
} // subdir/server.rs
#[launch]
pub fn just_a_fn() -> _ {
rocket::build().mount("/", routes![index])
}
#[get("/<_..>")]
async fn index() -> &'static str {
"Hello, world!"
} |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, thanks for Rocket
I'm a newb to rust, but I tried everything and I keep getting
error[E0468]: an
extern crate
loading macros must be at the crate root (for #[macro_use] extern crate rocket;)also I cannot use the use directive to import... all just because I'm not in /src, but /src/... That shouldn't be this hard... Can you please help me with that?
thanks
Beta Was this translation helpful? Give feedback.
All reactions