02 2023 档案
摘要:实现From 或 Into 这两个 trait, 可以进行类型的转换 如 impl From<B> for A 或 impl Into<B> for A,则有 B → A 这种类型转换,一般只需要实现 From,就可以自动实现 Into struct A; struct B; // 实现了 From
阅读全文
摘要:Rust中只能声明以下的变量为全局变量,声明时还需指定变量类型和值 const 变量 static 变量 /* const函数也可以对const变量进行赋值 const函数限制,不能使用for、while循环,只能使用loop 另外只能调用const函数 */ const fn get() -> i
阅读全文
摘要:enum Status { # 值的类型是 isize,默认0开始 Rich=0, Poor }
阅读全文