- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 94字
- 2021-07-02 23:07:16
Defining the variable value before use
While it is not enforced in some languages, a variable must have an initial value in Rust, even if it is zero. This is good practice, and also helps when it comes to debugging since all variables have known contents. If they didn't, there'd be a risk of undefined behavior.
Undefined behavior means that what the program does is anyone's guess. For instance, if variables did not have initial values, their values would be whatever happens to be in memory at the time that the value is allocated.
推薦閱讀
- ASP.NET Core:Cloud-ready,Enterprise Web Application Development
- UI設計基礎培訓教程
- Android應用程序開發與典型案例
- Mastering RabbitMQ
- Java 開發從入門到精通(第2版)
- OpenCV 3和Qt5計算機視覺應用開發
- Responsive Web Design with HTML5 and CSS3
- Oracle Database 12c Security Cookbook
- Hands-On Swift 5 Microservices Development
- Oracle Exadata專家手冊
- Building Serverless Applications with Python
- Bootstrap 4 Cookbook
- Mastering Linux Security and Hardening
- Mastering React
- R數據科學實戰:工具詳解與案例分析