fn main() {
    let string1 = String::from("abcd");
    let string2 = "xyz";
    let result = longest(string1.as_str(), string2);
    println!("The longest string is {}", result);
}
 
Listing 10-20: A main function that calls the longest function to find the longer of two string slices
Note that we want the function to take string slices, which are references, because we don’t want the longest function to take ownership of its parameters. We want to allow the function to accept slices of a String (the type stored in the variable string1) as well as string literals (which is what variable string2 contains).
The bolded quote should read:
We want to allow the function to accept slices of a String (the type stored in the variable string2)
because string1 is of type String and string2 is of type str& because String Literals Are Slices