Strings In Depth3 / 18
Up next

Compare String and &str

fn main() {
    let owned = String::from("rust");
    // String compares directly against a &str literal
    println!("{}", owned == "rust");
    println!("{}", owned.as_str() == "rust");
}
What you're solving

== works across the two types