- 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.
推薦閱讀
- Visual C++程序設計教程
- JavaScript從入門到精通(微視頻精編版)
- Learn TypeScript 3 by Building Web Applications
- Delphi程序設計基礎:教程、實驗、習題
- Game Programming Using Qt Beginner's Guide
- 數據結構簡明教程(第2版)微課版
- Full-Stack React Projects
- iOS應用逆向工程(第2版)
- The Complete Coding Interview Guide in Java
- C#開發案例精粹
- SQL 經典實例
- 零基礎學HTML+CSS
- 深度實踐KVM:核心技術、管理運維、性能優化與項目實施
- IPython Interactive Computing and Visualization Cookbook
- Web編程基礎:HTML5、CSS3、JavaScript(第2版)