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

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.

主站蜘蛛池模板: 深圳市| 思南县| 闽清县| 瑞金市| 西藏| 华池县| 云安县| 梨树县| 平遥县| 石屏县| 芒康县| 乐陵市| 辽阳市| 高碑店市| 三穗县| 云安县| 柳林县| 碌曲县| 兰西县| 东乡族自治县| 外汇| 辉县市| 榆社县| 孟州市| 台东县| 阳信县| 苍山县| 苗栗县| 临江市| 建昌县| 阿尔山市| 栾川县| 云浮市| 丰都县| 会泽县| 林芝县| 岑巩县| 荥阳市| 汾西县| 隆昌县| 翼城县|