1 2 3 4 5 6 7 8 9 10 11 12 13 14
// run-pass // rustc --test match_borrowed_str.rs.rs && ./match_borrowed_str.rs fn compare(x: &str, y: &str) -> bool { match x { "foo" => y == "foo", _ => y == "bar", } } pub fn main() { assert!(compare("foo", "foo")); }