3 fn f1(ref_string: &str) -> String {
5 "a" => "found a".to_string(),
6 "b" => "found b".to_string(),
7 _ => "not found".to_string()
11 fn f2(ref_string: &str) -> String {
13 "a" => "found a".to_string(),
14 "b" => "found b".to_string(),
15 s => format!("not found ({})", s)
19 fn g1(ref_1: &str, ref_2: &str) -> String {
20 match (ref_1, ref_2) {
21 ("a", "b") => "found a,b".to_string(),
22 ("b", "c") => "found b,c".to_string(),
23 _ => "not found".to_string()
27 fn g2(ref_1: &str, ref_2: &str) -> String {
28 match (ref_1, ref_2) {
29 ("a", "b") => "found a,b".to_string(),
30 ("b", "c") => "found b,c".to_string(),
31 (s1, s2) => format!("not found ({}, {})", s1, s2)
36 assert_eq!(f1("b"), "found b".to_string());
37 assert_eq!(f1("c"), "not found".to_string());
38 assert_eq!(f1("d"), "not found".to_string());
39 assert_eq!(f2("b"), "found b".to_string());
40 assert_eq!(f2("c"), "not found (c)".to_string());
41 assert_eq!(f2("d"), "not found (d)".to_string());
42 assert_eq!(g1("b", "c"), "found b,c".to_string());
43 assert_eq!(g1("c", "d"), "not found".to_string());
44 assert_eq!(g1("d", "e"), "not found".to_string());
45 assert_eq!(g2("b", "c"), "found b,c".to_string());
46 assert_eq!(g2("c", "d"), "not found (c, d)".to_string());
47 assert_eq!(g2("d", "e"), "not found (d, e)".to_string());