Skip to content

Instantly share code, notes, and snippets.

@davidpdrsn
Created August 24, 2022 11:18
Show Gist options
  • Save davidpdrsn/1b12787b4d01983a0fdf400e279cae24 to your computer and use it in GitHub Desktop.
Save davidpdrsn/1b12787b4d01983a0fdf400e279cae24 to your computer and use it in GitHub Desktop.
error[E0308]: mismatched types
--> src/main.rs:5:57
|
5 | let _: Router = Router::with_state(true).route("/", get(|_: State<String>| async {}));
| ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `String`
| |
| arguments to this function are incorrect
|
= note: expected struct `MethodRouter<bool, _>`
found struct `MethodRouter<String, _>`
note: associated function defined here
--> /Users/davidpdrsn/.cargo/registry/src/github.com-1ecc6299db9ec823/axum-0.6.0-rc.1/src/routing/mod.rs:154:12
|
154 | pub fn route(mut self, path: &str, method_router: MethodRouter<S, B>) -> Self {
| ^^^^^
error[E0308]: mismatched types
--> src/main.rs:5:21
|
5 | let _: Router = Router::with_state(true).route("/", get(|_: State<String>| async {}));
| ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `bool`
| |
| expected due to this
|
= note: expected struct `Router<(), Body>`
found struct `Router<bool, _>`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `foo` due to 2 previous errors
use axum::{extract::State, routing::get, Router};
#[tokio::main]
async fn main() {
let _: Router = Router::with_state(true).route("/", get(|_: State<String>| async {}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment