Fundamentals39 / 42
Up next

Slices

fn main() {
    let v = vec![1, 2, 3, 4, 5];
    // borrows part of v
    let mid: &[i32] = &v[1..4];
    let text = String::from("hello world");
    // a string slice
    let word: &str = &text[0..5];
    println!("{:?} {}", mid, word);
}
What you're solving

a borrowed window into a Vec or String