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

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.

主站蜘蛛池模板: 苍溪县| 新兴县| 久治县| 垫江县| 博兴县| 衡东县| 邢台市| 广平县| 南溪县| 嵊泗县| 平度市| 青州市| 兰溪市| 界首市| 双峰县| 安福县| 呼玛县| 卓尼县| 会理县| 兴国县| 和顺县| 芮城县| 永善县| 武宁县| 衡阳市| 荆州市| 广灵县| 甘泉县| 重庆市| 阿拉善左旗| 绥德县| 乌拉特后旗| 穆棱市| 兴化市| 保靖县| 蛟河市| 颍上县| 临桂县| 永福县| 南昌市| 丹东市|