Strings In Depth9 / 18
Up next

Slice by byte index

fn main() {
    let s = String::from("hello");
    // slicing is by BYTE index, not char count
    let hi = &s[0..2];
    println!("{hi}");
}
What you're solving

&s[a..b] uses byte offsets