- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 101字
- 2021-07-02 23:07:16
Const and static
Rust has two types of constants: consts and statics. Consts are sort of like aliases: their contents are sort of replaced on the place where they are used. The syntax is like this:
const PI: f32 = 3.1415927;
Statics are more like variables. They have a global scope of the program, and are defined as follows:
static MY_VARIABLE: i32 = 255;
They cannot be altered.
Rust is able to guess the types of local function variables. This is called local type inference. However, it is only local, so types of statics and consts must always be typed out.
推薦閱讀
- Deploying Node.js
- ASP.NET MVC4框架揭秘
- 騰訊iOS測試實踐
- Learning Chef
- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- MySQL 8 DBA基礎(chǔ)教程
- Mastering Articulate Storyline
- AutoCAD VBA參數(shù)化繪圖程序開發(fā)與實戰(zhàn)編碼
- Selenium Testing Tools Cookbook(Second Edition)
- Python 3.7從入門到精通(視頻教學(xué)版)
- 網(wǎng)絡(luò)數(shù)據(jù)采集技術(shù):Java網(wǎng)絡(luò)爬蟲實戰(zhàn)
- Xamarin Cross-Platform Development Cookbook
- Android初級應(yīng)用開發(fā)
- 信息學(xué)競賽寶典:基礎(chǔ)算法
- Spring Boot實戰(zhàn):從0開始動手搭建企業(yè)級項目