LukeMathWalker / zero-to-production

Code for "Zero To Production In Rust", a book on API development using Rust.
https://www.zero2prod.com
Apache License 2.0
5.43k stars 470 forks source link

code doesnot compile after 10.6.3.2 #248

Closed arindamchoudhury closed 4 months ago

arindamchoudhury commented 4 months ago

Hi,

I am following the book and coding with it.

After section 10.6.3.2, cargo check fails with

error[E0308]: mismatched types
  --> src\routes\login\post.rs:44:5
   |
44 | /     Ok(HttpResponse::SeeOther()
45 | |         .insert_header((LOCATION, "/"))
46 | |         .finish())
   | |__________________^ expected `Result<HttpResponse, LoginError>`, found `Result<HttpResponse, Error>`
   |
   = note: expected enum `Result<_, LoginError>`
              found enum `Result<_, anyhow::Error>`
note: return type inferred to be `Result<HttpResponse, LoginError>` here
  --> src\routes\login\post.rs:24:6
   |
24 | ) -> Result<HttpResponse, LoginError> {
   |      ^^^^^^
help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result`
   |
44 ~     Ok(Ok(HttpResponse::SeeOther()
45 |         .insert_header((LOCATION, "/"))
46 ~         .finish())?)
   |

For more information about this error, try `rustc --explain E0308`.
error: could not compile `zero2prod` (lib) due to 1 previous error

my repo: https://github.com/arindamchoudhury/zero2prod

Thanks in advance.