Skip to content

Type annotations needed for r.find() #3

Open
@farmeroy

Description

@farmeroy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions