摘要:
环境 Rust 1.56.0 VSCode 1.60.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/types/cast.html Rust 没有提供基础类型间的隐式转换,可以使用 as 关键字进行显式的类型转换。 示例 不支持隐式 阅读全文
posted @ 2021-11-30 23:12
jiangbo4444
阅读(389)
评论(0)
推荐(0)
摘要:
环境 Rust 1.56.0 VSCode 1.60.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/types/literals.html 示例 类型字面量 std::mem::size_of_val 可以获取变量所占用的字节数。 阅读全文
posted @ 2021-11-30 23:10
jiangbo4444
阅读(221)
评论(0)
推荐(0)
摘要:
环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/std/macro.assert.html 示例 assert! 第一个是布尔值,如果不为真,将会 panic 并打印后面自定义的错误信息。 fn main() { fn som 阅读全文
posted @ 2021-11-30 23:09
jiangbo4444
阅读(334)
评论(0)
推荐(0)
摘要:
环境 Rust 1.55.0 VSCode 1.59.1 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/variable_bindings.html Rust 通过静态类型提供类型安全,可以在变量绑定时进行类型注释。 然而,在大多数情况 阅读全文
posted @ 2021-11-30 23:06
jiangbo4444
阅读(169)
评论(0)
推荐(0)
摘要:
环境 Rust 1.55.0 VSCode 1.59.1 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/custom_types/constants.html Rust 有两种常量,可以在任意作用域声明,包括全局作用域。它们都需要显式的 阅读全文
posted @ 2021-11-30 23:04
jiangbo4444
阅读(141)
评论(0)
推荐(0)
摘要:
环境 Rust 1.55.0 VSCode 1.59.1 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/custom_types/enum/testcase_linked_list.html 使用枚举类型,实现一个单向的链表。Box:: 阅读全文
posted @ 2021-11-30 23:03
jiangbo4444
阅读(235)
评论(0)
推荐(0)
摘要:
环境 Rust 1.55.0 VSCode 1.59.1 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/custom_types/enum/enum_use.html 枚举类型的简单使用。 示例 类型别名 Self 就是实现当前 tra 阅读全文
posted @ 2021-11-30 23:01
jiangbo4444
阅读(223)
评论(0)
推荐(0)
摘要:
环境 Rust 1.55.0 VSCode 1.59.1 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/custom_types/enum.html enum 关键字允许创建一个从数个不同取值中选其一的枚举类型(enumeration) 阅读全文
posted @ 2021-11-30 23:00
jiangbo4444
阅读(142)
评论(0)
推荐(0)
摘要:
环境 Rust 1.55.0 VSCode 1.59.1 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/custom_types/structs.html Add a function rect_area which calculate 阅读全文
posted @ 2021-11-30 22:58
jiangbo4444
阅读(129)
评论(0)
推荐(0)
摘要:
环境 Rust 1.55.0 VSCode 1.59.1 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/custom_types/structs.html Add a function square which takes a Poin 阅读全文
posted @ 2021-11-30 22:57
jiangbo4444
阅读(140)
评论(0)
推荐(0)

浙公网安备 33010602011771号