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

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.

主站蜘蛛池模板: 泗阳县| 德庆县| 万安县| 莱西市| 墨脱县| 大田县| 盐亭县| 肥乡县| 灌阳县| 江孜县| 报价| 信丰县| 万源市| 格尔木市| 凉山| 故城县| 紫阳县| 房山区| 长白| 延庆县| 油尖旺区| 包头市| 门头沟区| 乌恰县| 日土县| 罗定市| 九江市| 团风县| 湖口县| 平昌县| 临安市| 基隆市| 兴山县| 张家口市| 古丈县| 平遥县| 砚山县| 孝感市| 古浪县| 辉县市| 大同市|