VScode 配置rust开发环境

记录一下在Visual Studio Code中配置Rust debug模式。

Rust 版本

安装Rust,具体到官网下载 https://www.rust-lang.org/,
由于我在windows环境上,因此安装了msvc版本

Default host: x86_64-pc-windows-msvc
rustup home:  D:Usersxxx.rustup

stable-x86_64-pc-windows-msvc (default)
rustc 1.46.0 (04488afe3 2020-08-24)
cargo 1.46.0 (149022b1d 2020-07-17)

用Cargo运行如下命令新建工程

PS D:vstestmain> cargo new RustDemo
     Created binary (application) `RustDemo` package

VSCode配置

​ 安装三个插件

  1. Rust for Visual Studio Code

  2. rust-analyzer

  3. Native Debug

    修改launch.json

/* launch.json */
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name":"(Windows) Launch"
            "type":"cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/target/debug/RustDemo.exe",
            "args": [],
            "cwd": "${workspaceFolder}"
        }
    ]
}
原文地址:https://www.cnblogs.com/langzou/p/13673601.html