Hi, I am new to Rust and am trying to set up Visual Studio Code in Windows.
I want the configuration to be similar to Visual studio:
- Select Debug/Release and run the corresponding cargo command
- Press F5 to run program in Debugger, Ctrl+F5 to run program without Debugger.
To do so, I installed the latest stable-msvc toolchain (1.32.0), alongwith rls and rustfmt, and the Codelldb+rls extensions for Visual Studio Code.
However, I cannot seem to make the program I wrote output anything on any console in VS Code. Debugging works like a charm though with lldb.
These are my config files:
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"sourceLanguages": [
"rust"
],
"preLaunchTask": "cargo build",
"internalConsoleOptions": "openOnSessionStart",
"program": "${workspaceRoot}/target/debug/${workspaceRootFolderName}",
"args": []
},
{
"type": "lldb",
"request": "launch",
"name": "Release",
"sourceLanguages": [
"rust"
],
"preLaunchTask": "cargo build release",
"internalConsoleOptions": "openOnSessionStart",
"program": "${workspaceRoot}/target/release/${workspaceRootFolderName}",
"args": []
}
]
}
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "cargo build",
"type": "shell",
"command": "cargo",
"args": [
"build"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$rustc"
},
{
"label": "cargo build release",
"type": "shell",
"command": "cargo",
"args": [
"build",
"--release"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$rustc"
}
]
}
This is also my first time using VS Code so I am most likely doing something stupid. I would be really grateful if someone pointed me towards what I'm doing wrong, and if possible, setting VS Code like I mentioned at the beginning of the post, if it is something that can be done. Thanks in advance!