// creates a variable named str and assigns it a string value of "Hello, world!" .
let str = "Hello, world!";
// creates a variable named str_slice and assigns it a reference to the first two characters of str .
let str_slice = &str[0..1];
// creates a variable named str_slice and assigns it a reference to the entire string.
let str_slice = &str[..];
// creates a variable named str_slice and assigns it a reference to the fourth character onwards.
let str_slice = &str[3..];