Rust 有没有办法使用任何文本作为函数名?就像是:
fn 'This is the name of the function' { ... }
Run Code Online (Sandbox Code Playgroud)
我发现它对测试功能很有用,其他语言也允许这样做。
函数名中不能有空格(大多数编程语言都是如此)。Rust 中函数名称的通常做法是用下划线替换空格,因此允许以下内容:
fn This_is_the_name_of_the_function { ... }
Run Code Online (Sandbox Code Playgroud)
尽管通常的做法会使用小写 t
| 归档时间: |
|
| 查看次数: |
286 次 |
| 最近记录: |