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

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.

主站蜘蛛池模板: 东乌珠穆沁旗| 宜昌市| 嫩江县| 区。| 中宁县| 北碚区| 翁牛特旗| 旬邑县| 浦县| 西乌珠穆沁旗| 靖边县| 建宁县| 和硕县| 柘荣县| 沾益县| 于都县| 博湖县| 五常市| 白水县| 铁岭县| 长岛县| 古田县| 若羌县| 普陀区| 监利县| 石阡县| 宽甸| 洱源县| 东兴市| 乐昌市| 息烽县| 思茅市| 乐山市| 西华县| 江阴市| 盐池县| 纳雍县| 虹口区| 鄂托克前旗| 南皮县| 普安县|