Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type annotations needed for r.find() #3

Open
farmeroy opened this issue Feb 25, 2023 · 1 comment
Open

Type annotations needed for r.find() #3

farmeroy opened this issue Feb 25, 2023 · 1 comment

Comments

@farmeroy
Copy link

farmeroy commented Feb 25, 2023

When writing the the return_error function in Chapter 3, the example code doesn't pass a concrete type to the find() method.
This results in the compiler throwing this error:

error[E0282]: type annotations needed
  --> src/main.rs:66:41
   |
66 |     } else if let Some(_invalidId) = r.find() {
   |                                         ^^^^ cannot infer type of the type parameter `T` declared on the associated function `find`
   |
help: consider specifying the generic argument
   |
66 |     } else if let Some(_invalidId) = r.find::<T>() {
   |                                             +++++

This error can be fixed by adding the return type to .find(): find::<InvalidId>()
I'm not sure if this is due to Warp changing since publication or maybe it is intentional to force us learners to read the Warp documentation.
If it's to force us to read the docs, then it's perfect! I definitely learned something. If this wasn't intentional, it's an easy fix I guess.

@a-bakos
Copy link

a-bakos commented Mar 1, 2023

Nice one @farmeroy - I just came to comment the same 👍 Good luck with your learning, this is an awesome book!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants