I am having some trouble with moving a function into a separate file when using the rocket library.
I am able to compile and run the getting-started-example from rockets web page, like this:
// main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
#[get("/")]
pub fn index() -> &'static str { "Hello, world!" }
fn main() { rocket::ignite().mount("/", routes![index]).launch(); }
But if I move the index()
function into its own file, in the same directory, like this:
// main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
mod index;
fn main() { rocket::ignite().mount("/", routes![index]).launch(); }
// index.rs
#[get("/")]
pub fn index() -> &'static str { "Hello, world!" }
I am then presented with the error message:
error[E0425]: cannot find value `static_rocket_route_info_for_index` in this scope
--> src/main.rs:8:41
|
8 | rocket::ignite().mount("/", routes![index]).launch();
| ^^^^^ not found in this scope
|
help: consider importing this static
|
5 | use crate::index::static_rocket_route_info_for_index;
|
What does this mean in this context and how do i fix it?