I'm trying to get a simple API up and running using rocket similar to this repo:
//! main.rs
use ptb_api; // my crate
#[rocket::main]
async fn main() -> Result<(), rocket::Error> {
ptb_api::rocket().launch().await
}
//! lib.rs
use rocket::{get, launch, routes};
#[get("/")]
fn index() -> &'static str {
"Hello, world!"
}
#[launch]
pub fn rocket() -> _ {
rocket::build().mount("/", routes![index])
}
# Cargo.toml
[dependencies]
rocket = "0.5.0-rc.2"
When I attempt to build I get this error:
error[E0308]: mismatched types
--> src\main.rs:4:46
|
4 | async fn main() -> Result<(), rocket::Error> {
| ____________________-------------------------_^
| | |
| | expected `Result<(), rocket::Error>` because of return type
5 | | ptb_api::rocket().launch().await
6 | | }
| |_^ expected `()`, found struct `Rocket`
|
= note: expected enum `Result<(), _>`
found enum `Result<Rocket<Ignite>, _>`
I am using nearly the same code as the repo I linked above. I can't tell why the linked repo builds and mine fails. It should be worth noting that I am using rocket version 0.5.0-rc.2
and the linked repo was using 0.5.0-rc.1
. And after cloning the repo and upgrading it, the same problem occurs. So something changed in rocket between release candidates, just not sure what.