我在一个类中有一个准系统功能,这是唯一的功能。
pub fn getfreq(note: char, mod: char, oct: i8) {}
我收到以下错误:
error: expected pattern, found keyword `mod`
--> src/main.rs:1:28
|
1 | pub fn getfreq(note: char, mod: char, oct: i8) {}
| ^^^
mod
与 Rust 相关吗?我只想用它来缩写“修饰符”。
最佳答案
I just want to use it for abbreviating 'modifier'.
mod
已经被 Rust 语言用来缩写 "module" .因此,它是一个关键字 — 一组不能用于其他任何内容的特定字符。您将需要选择另一个名称。
有many keywords in Rust除非出于特定语言的目的,否则不得使用它们。
关于函数参数报告 "error expected pattern, found keyword ` mod`",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44308812/