Visual Studio Rust

  



  1. Visual Studio Code Azure Learn how to get started with Rust - set up the environment, write a program, and use the Cargo build system. Write a simple 'Hello, world!' Use Cargo, Rust's package manager and build system. Bookmark Add to collection Prerequisites. A Windows, Mac, or Linux computer; Knowledge of how to download programs.
  2. Visual Studio Code. Lay the foundation of knowledge you need to build fast and effective programs in Rust. In this learning path, you'll: Install the tools you need to write your first lines of Rust code. Learn basic concepts in Rust. Learn how to handle errors.

Visual Studio Code Rust Autocomplete

I want to build a rust-project from visual studio 2019 (windows). Here is what I have done so far: Downloaded and installed rust. Compiling via rustc from the command line is possible. Installed the Rust Add-On in Visual Studio. Set 'Toolchain to use' from 'nightly' to 'beta'. This solved an issue where I got the message that rls could not be.

I recently wanted to debug a Rust program on Windows that I had written, and was struggling with how to get it to work. Since there was quite a lot of hoops to jump through to get it to work, I though I should share it with other people as well. Is battlefield 4 for mac. I've written this blog post from memory and I'm far from an expert in LLVM or Rust, so if you see something strange here then let me know.

Visual studio rust plugin

The drawback of this approach is that you can't debug applications built using the MSVC toolchain. If you know how to do this, please tell me. I would really appreciate it.

UPDATE 2018-02-02:
As Stuart Dootson pointed out to me, there's a guide on how to debug applications using the MSVC toolchain here. I haven't tried this out myself, but it looks promising. Game installers for mac. Thanks Stuart!

1. Install LLVM

First we need to install LLVM which is a compiler infrastructure. Part of LLVM is LLDB which is the debugger we're going to use. The latest version of LLVM doesn't include Python support for LLDB which is required for the VSCode extension, so we need to download a custom built version and install that.

2. Install Python

We now need to install Python v3.5 (Not v3.6).
https://www.python.org/downloads/release/python-354/

If you installed the x64 version of LLVM, make sure that you install the x64 version of Python as well, otherwise you will encounter problems later on.

3. Make sure it works

Make sure that lldb can use scripting. If this doesn't work, make sure that both LLVM and Python is on PATH.

Write exit() to close the Python interpreter and then CTRL+C to break out of LLDB.

4. Install the VSCode extension

We now need to install the vscode-lldb extension for Visual Studio Code. This is what makes it possible to debug our Rust code from Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb

Visual Studio Rust

5. Install the Rust GNU toolchain

Since LLDB doesn't work with the msvc compiler, we need to install the Rust GNU toolschain and use that one. This have some drawbacks though such as we won't be able to intop with software produced by Visual Studio.

6. Set the active toolchain

We now need to set the Rust GNU toolchain as the active toolchain. We do this by using the rustup command again.

Visual Studio RustRustRust

Visual Studio Rust

We should now verify what our toolchain configuration look like by using rustup show.

7. Create a project

Create a new project called hello_world.

Visual Studio Rust Build

Open Visual Studio Code and go to ./src/main.rs and place a breakpoint.

8. Edit launch.json

Visual Studio Rust Extension

Press F5 to run the project. A selection box will appear that will ask you what environment you want to use. Choose LLDB Debugger here. This will open up the launch.json file, and here we need to tell Visual Studio Code how to launch our project. Edit the file so it looks similar to this:

9. Profit

Vscode Rust

Press F5 again. You should now be debugging your code.