由于rustrover不是免费的,此处教学搭建一套基于vscode的rust开发环境,可运行,可调式
1.下载vscode1.91.1
Download Visual Studio Code - Mac, Linux, Windows
2.下载插件
打开网站下载插件 rust-analyzer-0.4.2049、vscode-lldb-1.10.0、debug-0.27
Extensions for Visual Studio family of products | Visual Studio Marketplace
打开链接后 依次搜索,并下载对应的拓展包
3.安装插件
打开vscode
4.启用插件
安装后可能没启用,右键启用即可
5.确保本机已安装rust
cmd 后输入cargo,显示如下说明已正确安装rust
未安装则下载安装
https://static.rust-lang.org/dist/rust-1.80.0-x86_64-pc-windows-gnu.msi
6.新建项目
cargo new demo
7.调试配置
工程下新建.vscode文件夹
新建文件tasks.json,每次运行之前进行build,也就是生成exe文件
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "cargo",
"args": [
"build"
]
}
]
}
新建文件 launch.json,调试内容
{
"version": "0.2.0",
"configurations": [
{
"name": "(Windows)启动",
"preLaunchTask": "build",
"type": "lldb",
"MIMode": "lldb",
"request": "launch",
"program": "${workspaceFolder}/target/debug/${workspaceFolderBasename}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false
}
]
}
8.开始调试