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 required for as_ref #148

Closed
tathanhdinh opened this issue May 23, 2018 · 4 comments
Closed

Type annotations required for as_ref #148

tathanhdinh opened this issue May 23, 2018 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@tathanhdinh
Copy link
Contributor

I've found error when compiling bat with rustc 1.28.0-nightly:

error[E0283]: type annotations required: cannot resolve `std::string::String: std::convert::AsRef<_>`
  --> src/features.rs:50:43
   |
50 |             print!("{}", Green.paint(word.as_ref()));
   |                                           ^^^^^^

error: aborting due to previous error

that seems because of changes in type inference on nightly and beta (others found similar problems).

IMHO, that is because of there are two possibilities for type of word.as_ref(): &str and &[u8] ; this can be "fixed" using slice notation, like that:

print!("{}", Green.paint(&word[..]));

which will compile on both stable and nightly.

@sharkdp sharkdp added bug Something isn't working good first issue Good for newcomers labels May 24, 2018
@sharkdp
Copy link
Owner

sharkdp commented May 24, 2018

Thank you for taking the time to report this!

@tathanhdinh
Copy link
Contributor Author

tathanhdinh commented May 24, 2018

Many thanks!!!
I can make a PR if you don't mind.

@sharkdp
Copy link
Owner

sharkdp commented May 24, 2018

Sounds great!

@sharkdp
Copy link
Owner

sharkdp commented May 25, 2018

Closed via #153

@sharkdp sharkdp closed this as completed May 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants