gpt4 book ai didi

rust - 如何让 VS Code 构建和运行 Rust 程序?

转载 作者:行者123 更新时间:2023-11-29 07:46:58 25 4
gpt4 key购买 nike

我一直在使用 VS Code ,我想知道如何构建一个包含这些命令的 task.json 文件。 cargo buildcargo run [ARGS] cargo run --release -- [ARGS]

我试过用 documentation 制作一个在 task.json 上。我一直收到 No such subcommand 错误。

示例:

{
"version": "0.1.0",
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "cargo",

// The command is a shell script
"isBuildCommand": true,

// Show the output window only if unrecognized errors occur.
"showOutput": "silent",

"tasks": [{
"taskName": "run test",
"version": "0.1.0",
"command": "run -- --exclude-dir=node_modules C:/Users/Aaron/Documents/Github/",
"isShellCommand": true,
"showOutput": "always"
},
{
"taskName": "run",
"version": "0.1.0",
"args": [ "--"
, "--exclude-dir=node_modules"
, "C:/Users/Aaron/Documents/Github/"
]
"isShellCommand": true,
"showOutput": "always"
}]
}

最佳答案

可能这些答案已经过时了,这是我的 tasks.json,它实现了 cargo run、cargo build 和一个 cargo 命令来运行当前打开的示例...

关键是指定问题匹配器,这样您就可以点击错误:

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "cargo run example",
"type": "shell",
"command": "cargo run --example ${fileBasenameNoExtension}",
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo run",
"type": "shell",
"command": "cargo run",
"problemMatcher": [
"$rustc"
]
},
{
"label": "cargo build",
"type": "shell",
"command": "cargo build",
"problemMatcher": [
"$rustc"
]
},
]
}

关于rust - 如何让 VS Code 构建和运行 Rust 程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30627611/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com