官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 天等县| 福建省| 东丰县| 独山县| 陇南市| 灵丘县| 宁陵县| 阜康市| 呼伦贝尔市| 西畴县| 上饶县| 茂名市| 阿勒泰市| 临武县| 武鸣县| 会同县| 铁岭县| 扶绥县| 江永县| 鄂尔多斯市| 临汾市| 涿鹿县| 定结县| 罗源县| 鄄城县| 新和县| 乾安县| 太仓市| 南乐县| 惠东县| 溆浦县| 连州市| 南昌县| 马鞍山市| 宜昌市| 霍邱县| 嘉荫县| 贵溪市| 武乡县| 若尔盖县| 竹山县|