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

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.

主站蜘蛛池模板: 历史| 永顺县| 高淳县| 孟州市| 土默特左旗| 正蓝旗| 柳林县| 汤阴县| 建昌县| 松溪县| 涟水县| 武邑县| 德格县| 迭部县| 乌拉特后旗| 芦溪县| 图木舒克市| 郴州市| 介休市| 炎陵县| 宣武区| 临西县| 马山县| 霍山县| 神木县| 铜鼓县| 尼玛县| 呼和浩特市| 常熟市| 泰和县| 蒙自县| 玛多县| 景东| 定兴县| 林口县| 闵行区| 新宁县| 宁南县| 垣曲县| 木里| 宣化县|