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

The reference type

A reference is written in one of three ways: &, ref, or ref mut:

let mut var = 4; 
let ref_to_var = &var; 
let ref second_ref = var; 
let ref mut third_ref = var; 

The references are all equivalent here. Note, however, that the preceding code doesn't work as it is due to mutable reference rules. Rust allows several immutable reference to a thing, but if a mutable reference is taken, no other references may exist at the time. Therefore, the last line would not work, since there are already two active references to var.

主站蜘蛛池模板: 诏安县| 嘉峪关市| 西华县| 西青区| 丰镇市| 梅河口市| 宁化县| 龙南县| 台安县| 青田县| 三明市| 阜宁县| 湟源县| 连山| 宁海县| 山阴县| 榆树市| 汾西县| 汽车| 张家港市| 漾濞| 惠安县| 仪征市| 新安县| 大埔县| 辉南县| 淮北市| 东莞市| 托克逊县| 余江县| 台中县| 衡水市| 武邑县| 光泽县| 台北市| 宿迁市| 宁海县| 闽侯县| 东乡县| 丰镇市| 靖边县|