格式:
名 + 文档链接 | 曰
| `[函数名](对应文档链接)` | 浓缩描述 |
| ------------------------ | -------- |
| `[函数名](对应文档链接)` | 浓缩描述 |
注意:表格的第一列,基本都是网址链接,只不过它的 css 格式是代码块。
目录
按功能/主题分类
基础
fn main |
main 函数是一个特殊的函数:在可执行的 Rust 程序中,它总是最先运行的代码 |
unwrap() |
Ok/Some就返回里面的值,Err/None 就 panic,让程序崩溃 |
try!() |
语法糖?, Ok/Some就返回里面的值(比如:赋个值什么的), Err/None 就将错误值,返回到上层(函数) |
输出
宏
条件编译
cfg()对源代码进行条件区分,true就有,false剔除编译阶段
cfg_attr()对第一参数作为条件,那(后续参数)true就有,false没有
属性(Attribute)
属性,是 Rust 对各项标记/相关语法形式的统称,看语法:
- (内属性)InnerAttribute:
#![ Attr ]:apply to the item that the attribute is declared within. (应用 Attr 所定义的项)
- (外属性)OuterAttribute:
#[ Attr ]:apply to the thing that follows the attribute. (应用 Attr )
- Rust 内置的属性
代码生成
测试
- 注意: 测试模式是通过,
rustc --test命令或是cargo test启用的。
派生(derive)