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

Manipulating an array or vector via slices

Both arrays and vectors can be accessed using a value (such as my_vec[4]). However, if you want to manipulate a section of the array, then you would take a slice from the array. A slice is like a window to a part of the original thing.

To create a slice, use this:

let my_slice = &my_vec[1..5];  

A slice also has no predefined size: it can be 2 bytes, or it can be 202 bytes. Due to this, the size of the slice is not known at compile time. This is important to know, because it prevents certain methods from working.

主站蜘蛛池模板: 墨竹工卡县| 乐业县| 涟水县| 舟山市| 绥芬河市| 自贡市| 铜鼓县| 襄汾县| 东安县| 曲周县| 聂荣县| 枝江市| 盐山县| 通山县| 融水| 彭泽县| 磐石市| 岑溪市| 临洮县| 喀喇沁旗| 乌拉特前旗| 邹平县| 钟祥市| 潜江市| 郯城县| 云安县| 南澳县| 巴彦淖尔市| 保定市| 东至县| 清丰县| 三原县| 体育| 宜川县| 济南市| 海口市| 如东县| 横峰县| 呼图壁县| 高阳县| 光山县|