上一页 1 ··· 58 59 60 61 62 63 64 65 66 ··· 119 下一页
摘要: 环境 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 阅读(167) 评论(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 阅读(117) 评论(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 阅读(135) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/move/mut.html 示例 在发生所有权转移时,数据的可变性可能发生改变。 main.rs fn main() { 阅读全文
posted @ 2021-12-17 20:05 jiangbo4444 阅读(108) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/move.html 示例 因为变量要负责释放他们的资源,所有一个资源只能有一个所有者,避免重复释放,其中引用不拥有资源。 阅读全文
posted @ 2021-12-17 20:04 jiangbo4444 阅读(235) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/scope/raii.html 示例 在 Rust 中,会强制实行 RAII(Resource Acquisition Is Ini 阅读全文
posted @ 2021-12-17 20:02 jiangbo4444 阅读(186) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/generics/phantom.html 示例 虚类型参数不会在运行时出现,仅在编译时进行静态类型检查的类型参数。 main.rs 阅读全文
posted @ 2021-12-11 21:35 jiangbo4444 阅读(188) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/generics/phantom/testcase_units.html 示例 main.rs use std::marker::P 阅读全文
posted @ 2021-12-11 21:35 jiangbo4444 阅读(73) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/generics/assoc_items/types.html 示例 main.rs struct Container(i32, i 阅读全文
posted @ 2021-12-11 21:33 jiangbo4444 阅读(199) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/generics/new_types.html 示例 如果直接使用基础类型容易误导和出错,可以考虑定义一种新的类型,来提供编译保证。 阅读全文
posted @ 2021-12-11 21:31 jiangbo4444 阅读(146) 评论(0) 推荐(0)
上一页 1 ··· 58 59 60 61 62 63 64 65 66 ··· 119 下一页