(更新:rust-analyzer 也有自動產生 launch.json 的功能。可以停留在 main.rs 上,按 F1,選取 "rust-analyzer: Generate launch configuration" 即可。)

留個筆記,不然每次都要靠 google....

{
    // 使用 IntelliSense 以得知可用的屬性。
    // 暫留以檢視現有屬性的描述。
    // 如需詳細資訊,請瀏覽: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type":"lldb",
            "request": "launch",
            "name": "Debug",
            "program": "${workspaceFolder}/target/debug/${workspaceFolderBasename}",
            "args": [],
            "cwd": "${workspaceRoot}",
            "sourceLanguages": [
                "rust"
            ]
        }
    ]
}

然後記得要按 VS Code 自已的 debug/run 按鈕去執行,不要按 main() 上方的 "Run/Debug" inlay。後者不會吃 launch.json 中的 args

參考來源:Setting up a generic launch.json for Rust in VSCode

By closer

發表迴響