I started learning Rust, and I found Visual Studio Code an excellent IDE for experimenting with Rust (in the future, I’ll also evaluate my beloved Eclipse).
I thought I’d share this experience.
Assuming you have already installed Rust, let’s create a project
1 2 |
❯ cargo new hello Creating binary (application) `hello` package |
Open Visual Studio Code in the “hello” directory
1 2 |
cd hello code . |
We get syntax highlighting for the Rust source but nothing more:
Let’s install the “Rust Extension Pack”, which includes several Rust-related plugins:
Returning to our Rust project, we can see that the “target” folder has been created with compiled binaries, thanks to the installed extension:
Moreover, we now have the code lens to run our Rust program in the Rust editor. And we also have hovering (and, of course, code completion!):
Moreover, we also get live validation in the editor with possible error markers and quickfixes when available.
Let’s run our Rust program and see the output (after compilation) in the Console:
Let’s try to debug it, and we get a message telling us to install another extension:
Let’s go with CodeLLB:
And here we are: I set a breakpoint, and the debugger correctly stopped there:
Happy learning and coding with Rust! 😉