我正在尝试找到一种有效的方法来解构 Rust 中的向量。将索引上的值分配给相应的变量。我已经浏览了文档但无法找到答案。
let (frequency, samplingrate, samples, slope, duration, steps) = (input[0], input[1], input[2], input[3], input[4], input[5]);
Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用 ForkExec() 但我无法完成这项工作,syscall.Stdout 和 os.Stdout 之间有区别吗?
这是我尝试运行的代码的一个小例子。
command := "/usr/bin/echo"
args := []string{"Hello there."}
attr := new(syscall.ProcAttr)
attr.Env = os.Environ()
attr.Files = []uintptr{uintptr(syscall.Stdin), uintptr(syscall.Stdout), uintptr(syscall.Stderr)}
pid , err := syscall.ForkExec(command, args, attr)
if err != nil {
log.Fatal(err)
}
fmt.Println(pid)
Run Code Online (Sandbox Code Playgroud)
输出未显示在屏幕上。
非常感谢您的帮助。