1

I just started learning Rust and tried to write make a simple HTTP request using reqwest

I tried to create a reqwest::Client, but VSCode didn't give me a corresponding completion.

Screenshot

But after I wrote the code myself, VSCode showed me that it knows the type of the expression.

Screenshot

And after I wrote let res = client., it still does not give me any completion about this.

Screenshot

Why can this happen?

James Z
  • 12,209
  • 10
  • 24
  • 44
Wynell
  • 39
  • 6

1 Answers1

5

I'm guessing you're using the Rust extension for VSCode instead of rust-analyzer. Both of these extensions provide a language server, which ultimately is what's responsible for code suggestions.

I ran into similar problems with subpar autocomplete when using VSCode with the Rust extension. Uninstalling that, and installing the rust-analyzer extension instead, resulted in a far superior experience. The rust-analyzer language server is now also officially recommended moving forwards, as stated here:

The RFC proposes a plan to adopt rust-analyzer as Rust's official LSP implementation.

where LSP is an acronym for Language Server Protocol.

John H
  • 14,422
  • 4
  • 41
  • 74