- 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.
推薦閱讀
- 數據科學實戰手冊(R+Python)
- Qt 5 and OpenCV 4 Computer Vision Projects
- Visual FoxPro程序設計教程
- 單片機應用技術
- Troubleshooting PostgreSQL
- Kotlin從基礎到實戰
- 編程與類型系統
- Mastering Data Mining with Python:Find patterns hidden in your data
- Mastering Akka
- Unity 2018 Augmented Reality Projects
- Java圖像處理:基于OpenCV與JVM
- Unity 5.X從入門到精通
- Web編程基礎:HTML5、CSS3、JavaScript(第2版)
- 會當凌絕頂:Java開發修行實錄
- 計算機應用基礎