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

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.

主站蜘蛛池模板: 榆树市| 大余县| 山东省| 渭南市| 彩票| 宁陕县| 合水县| 塘沽区| 临夏市| 永康市| 湾仔区| 黄陵县| 龙南县| 宁明县| 万年县| 兴安盟| 铁岭县| 通渭县| 大港区| 五指山市| 盈江县| 呼玛县| 德格县| 武夷山市| 武清区| 金山区| 腾冲县| 封丘县| 胶州市| 黎平县| 兴安盟| 肇州县| 固安县| 涿鹿县| 唐海县| 深圳市| 噶尔县| 禹州市| 黄陵县| 宁夏| 二手房|