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

Use of the match syntax requires Deref in scope #94

Closed
anna-is-cute opened this issue Jun 13, 2018 · 3 comments
Closed

Use of the match syntax requires Deref in scope #94

anna-is-cute opened this issue Jun 13, 2018 · 3 comments

Comments

@anna-is-cute
Copy link

In order to match in templates, std::ops::Deref must be in scope.

Otherwise, confusing errors abound:

error[E0599]: no method named `deref` found for type `&std::option::Option<std::string::String>` in the current scope
 --> webserver/src/routes/web/base.rs:7:10
  |
7 | #[derive(Template)]
  |          ^^^^^^^^
  |
  = help: items from traits can only be used if the trait is in scope
  = note: the following trait is implemented but not in scope, perhaps add a `use` for it:
          `use lazy_static::Deref;`

This issue is two-part:

  1. I don't think this should be necessary. The more imports that have seemingly no use in the actual code, the less clear the code is.
  2. Until it isn't necessary, it should be documented.
@djc
Copy link
Owner

djc commented Jun 13, 2018

Can you add a minimal test case? IIRC we already import an aliased Deref in relevant scopes to prevent this sort of issue.

@anna-is-cute
Copy link
Author

anna-is-cute commented Jun 13, 2018

I made a repo. cargo run it.

@djc djc closed this as completed in 70fc6d2 Jun 14, 2018
@djc
Copy link
Owner

djc commented Jun 14, 2018

Your example repo works with master after 70fc6d2, thanks for reporting!

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