0%

VS Code Settings for Rust

VS Code配置

VS Code 支持Rust 插件安装

Rust, 语言支持插件

crates, 用来检查Rust项目依赖的版本情况

Better TOML, 支持Cargo配置文件编辑

C/C++ for Visual Studio Code, Windows环境Debug, https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

CodeLLDB, Linux环境Debug, https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb

Debug 设置

  1. VS Code File -> Preferences -> Settings ,找到Debug,配置可以在任意位置下断点

  2. 选择“Debug-> Add Configuration”

  3. 如果是Windows环境,选择 C++ (Windows)
    如果是Mac环境,选择 LLDB: Custom Launch

    如上步骤将创建 launch.json。需要手动配置”program”项目的可执行程序路径。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
"version": "0.2.0",
"configurations": [
// --- For Windows
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/target/debug/hello_console.exe", //配置程序路径
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true
},
// --- For Mac
{
"name": "(OSX) Launch",
"type": "lldb",
"request": "launch",
"program": "${workspaceRoot}/target/debug/foo",//Mac配置程序路径
"args": [],
"cwd": "${workspaceRoot}",
}
]
}

然后,使用F5, 开始Debug吧!

参考

https://www.forrestthewoods.com/blog/how-to-debug-rust-with-visual-studio-code/

Welcome to my other publishing channels