上一页 1 ··· 51 52 53 54 55 56 57 58 59 ··· 112 下一页
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/lifetime/struct.html 示例 main.rs #[derive(Debug)] struct Borr 阅读全文
posted @ 2021-12-17 20:44 jiangbo4444 阅读(62) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/lifetime/methods.html 示例 main.rs struct Owner(i32); impl Own 阅读全文
posted @ 2021-12-17 20:43 jiangbo4444 阅读(84) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/lifetime/fn.html 示例 main.rs fn print_one<'a>(x: &'a i32) { p 阅读全文
posted @ 2021-12-17 20:42 jiangbo4444 阅读(64) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/lifetime.html 示例 生存期(lifetime),也叫生命周期等,rust 使用生存期来保证所有的借用都是有 阅读全文
posted @ 2021-12-17 20:14 jiangbo4444 阅读(119) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/lifetime/explicit.html 示例 生存期的标注,使用撇号来标注。 main.rs // 标注了两个生存 阅读全文
posted @ 2021-12-17 20:14 jiangbo4444 阅读(73) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/borrow/ref.html 示例 取引用可以使用 & 和 ref 关键字,它们有各自的使用场景。 main.rs # 阅读全文
posted @ 2021-12-17 20:12 jiangbo4444 阅读(96) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/borrow/alias.html 示例 进行借用时,可以以不可变借用多次。但是在不可变借用的时候,不能进行可变借用。同 阅读全文
posted @ 2021-12-17 20:11 jiangbo4444 阅读(470) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/borrow/mut.html 示例 main.rs #[derive(Clone, Copy)] struct Boo 阅读全文
posted @ 2021-12-17 20:09 jiangbo4444 阅读(160) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/borrow.html 示例 通过引用来传递对象,在 rust 中称为借用。 main.rs fn eat_box_i3 阅读全文
posted @ 2021-12-17 20:08 jiangbo4444 阅读(110) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/move/partial_move.html 示例 main.rs fn main() { #[derive(Debug 阅读全文
posted @ 2021-12-17 20:06 jiangbo4444 阅读(129) 评论(0) 推荐(0)
上一页 1 ··· 51 52 53 54 55 56 57 58 59 ··· 112 下一页