Slice is a view to a continuous sequence of data in Rust. A good pre-read: Rust: References
Notation
let s = String::from("abcdefg");// grab all data
let slice1 = &s[..];
println!("{}", slice1); // "abcdefg"// beginning to an exclusive end index
let slice2 = &s[..2];// between inclusive start index to exclusive end index
let slice3 = &s[0..2];
println!("{} == {}", slice2, slice3); // ab == ab// from inclusive start index to the end
let slice4 = &s[5..];
println!("{}"…