concept slice in category rust

This is an excerpt from Manning's book Rust in Action.
Slices are dynamically sized array-like objects. The term dynamically sized means that their size is not known at compile time. Yet, like arrays, they don’t expand or contract. The use of the word dynamic in dynamically sized is closer in meaning to "dynamic typing" rather than movement. The lack of compile-time knowledge explains the distinction in the type signature between an array (
[T; n]) and a slice ([T]).Slices are important because it’s easier to implement traits for slices than arrays. Traits are how Rust programmers add methods to objects. As
[T; 1],[T; 2], …,[T; n]are all different types, implementing traits for arrays can become unwieldy. Creating a slice from an array is easy and cheap because it doesn’t need to be tied to any specific size.Another very important use for slices is their ability to act as a view on arrays (and other slices). The term "view" here is taken from database technology and means that slices can gain fast, read-only access of data without needing to copy anything around.
The rub with slices is that Rust wants to know the size of every object in your program and they’re defined as not having a compile-time size. References to the rescue. As mentioned in the discussion about the use of the term dynamically sized, their size is fixed in memory. They’re made up of two
usizecomponents (a pointer and a length). That’s why you’ll typically see slices referred to in their referenced form (&[T]), such as string slices that take the notation&str.
The goal of this section is to support printing out n lines of context that surround a match. To get there, we will need to segue somewhat and explain what arrays, slices and vectors are. The most useful type for this exercise is the vector. To learn about vectors though, we need to start by learning about its two simpler cousins.