Rust in VS Code - Edit, Build, and Debug
- Brent Lewis
- May 29, 2022
- 1 min read
Follow these steps to configure VS Code as an IDE for Rust. Once complete, starting debugging will (differentially) build the Rust project, and launch it with the debugger attached.
Install
Create Project
cargo new hello_cargo
settings.json
{
"editor.formatOnSave": true,
"debug.allowBreakpointsEverywhere": true
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cargo",
"command": "build",
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
},
"label": "Rust: cargo build - hello_cargo"
}
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceRoot}/target/debug/hello_cargo.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"console": "externalTerminal",
"preLaunchTask": "Rust: cargo build - hello_cargo"
}
]
}
Comments