top of page
Search

Rust in VS Code - Edit, Build, and Debug

  • Writer: Brent Lewis
    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"
        }
    ]
}
 
 
 

Recent Posts

See All
Tokio on ESP32

There's an example of using Tokio on ESP32 platforms here. However, it took me a long time to discover the same thing in the context of...

 
 
 
Debugging Rust on ESP32-S3

{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information,...

 
 
 
Mixed Debugging with Dart and Rust

If you've ever worked with native interop, be it with Dart and Rust or otherwise, you recognize the value in mixed debugging. The idea is...

 
 
 

Comments


Post: Blog2_Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Social Dev. Proudly created with Wix.com

bottom of page