蜜月期后的 Rust 感受 #23
jiacai2050
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
no_std功能使 Rust 适用于嵌入式系统,生成与 C 语言一样小的二进制文件。{:#x?}格式化指令可以漂亮地打印十六进制的结构体,极大地方便了调试。0b0000_1011_1000_0000)更清晰且不易出错,并明确编码了位宽和符号。match语句替代了 C 的三元运算符,避免了其潜在问题。paste!crate 提供了宏中 token 连接的功能,类似于 C 预处理器的##运算符。unsafe关键字允许执行某些不安全的操作,但在 Rust 中应该谨慎使用,因为 Rust 会迫使你关注代码的安全性。anyhow!crate 和RUST_BACKTRACE方便错误追踪和调试。asm!语法使得内联汇编在 Rust 中比 C 语言更容易且更健壮。--pretty=expanded和cargo expand可以查看 Rust 代码经过宏展开后的结果,有助于理解代码的实际执行过程。Beta Was this translation helpful? Give feedback.
All reactions