2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2012-12-06 18:32:13 -08:00
|
|
|
// rustc --test match_borrowed_str.rs.rs && ./match_borrowed_str.rs
|
|
|
|
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2014-05-19 23:19:56 -07:00
|
|
|
fn compare(x: &str, y: &str) -> bool {
|
|
|
|
match x {
|
2012-12-06 18:32:13 -08:00
|
|
|
"foo" => y == "foo",
|
|
|
|
_ => y == "bar",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-19 23:19:56 -07:00
|
|
|
pub fn main() {
|
2013-03-28 18:39:09 -07:00
|
|
|
assert!(compare("foo", "foo"));
|
2012-12-06 18:32:13 -08:00
|
|
|
}
|