VS Code/CLion + Rust

Add to enverment vars:
CARGO_HOME:F:\.cargo
RUSTUP_HOME:F:\.rustup
Add %CARGO_HOME%\bin to PATH

Download rustup-init.exe from https://www.rust-lang.org/zh-CN/tools/install,
copy rustup-init.exe to %CARGO_HOME%\bin\rustup.exe

cmd:
set RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup

Rust配置镜像源
rustup toolchain install stable-x86_64-pc-windows-msvc
rustup component add rust-analysis --toolchain stable-x86_64-pc-windows-msvc
rustup component add rust-src --toolchain stable-x86_64-pc-windows-msvc
rustup component add rls --toolchain stable-x86_64-pc-windows-msvc

rustup toolchain install stable-i686-pc-windows-msvc
rustup component add rust-analysis --toolchain stable-i686-pc-windows-msvc
rustup component add rust-src --toolchain stable-i686-pc-windows-msvc
rustup component add rls --toolchain stable-i686-pc-windows-msvc

rustup toolchain install stable-x86_64-pc-windows-gnu
rustup component add rust-analysis --toolchain stable-x86_64-pc-windows-gnu
rustup component add rust-src --toolchain stable-x86_64-pc-windows-gnu
rustup component add rls --toolchain stable-x86_64-pc-windows-gnu

rustup toolchain install stable-i686-pc-windows-gnu
rustup component add rust-analysis --toolchain stable-i686-pc-windows-gnu
rustup component add rust-src --toolchain stable-i686-pc-windows-gnu
rustup component add rls --toolchain stable-i686-pc-windows-gnu

rustup show


1:Use VS Code
Install VS Code x64-1.46.1, extract vscode_plugin.7z to C:\Users\li\.vscode, 
Or install blow extensions online:
rust-analyzer
CodeLLDB
Better TOML

Tips: lldb debugger better than msvc and gdb

运行 - 启动调试,弹出警告框,点击确定,再点击YES,CodeLLDB会自动创建launch.json
打开左侧debug tab,选择对应的运行配置,即可开始调试

注意:
VS2015与CdoeLLDB有冲突,会导致报错:
Debug adapter exit code=3221225620, signal=null.
Rename C:\Program Files (x86)\Microsoft Visual Studio 14.0 to:
C:\Program Files (x86)\Microsoft Visual Studio 14.0_bak

如果是gdb和msvc:
Terminal - Configure Tasks - rust: cargo build
Run - Start Debugging - C++ (Windows)
This should create and open launch.json, edit:
"preLaunchTask": "rust: cargo build",
"program": "${workspaceRoot}/target/debug/${workspaceFolderBasename}.exe",
"externalConsole": true
If use MinGW, add:"miDebuggerPath": "D:/Qt/Qt5.14.2/Tools/mingw730_64/bin/gdb.exe",


2:Use CLion
rustup toolchain install stable-x86_64-pc-windows-gnu
rustup default stable-x86_64-pc-windows-gnu
rustup show
Download CLion-2020.1.2.exe, intellij-toml-0.2.124.40-201.zip, intellij-rust-0.2.125.3191-201.zip
Install CLion and plugins
If direct launch CLion, error info will show in Setting - Languages - Rust - Standard Library:(Download via rustup), 
you need open VSCode, then will display same message - "Rust Src", click install
CLion debug Rust exe only support MinGW64, install and set Settings - Build - Toolchains - MinGW - Environment: D:\Qt\Qt5.14.2\Tools\mingw730_64
You can start debugging