1*d4726bddSHONG Yifan extern crate mod1; 2*d4726bddSHONG Yifan greeter(name: &str) -> String3*d4726bddSHONG Yifanpub fn greeter(name: &str) -> String { 4*d4726bddSHONG Yifan format!("Hello, {name}!") 5*d4726bddSHONG Yifan } 6*d4726bddSHONG Yifan default_greeter() -> String7*d4726bddSHONG Yifanpub fn default_greeter() -> String { 8*d4726bddSHONG Yifan greeter(&mod1::world()) 9*d4726bddSHONG Yifan } 10*d4726bddSHONG Yifan 11*d4726bddSHONG Yifan #[cfg(test)] 12*d4726bddSHONG Yifan mod test { 13*d4726bddSHONG Yifan #[test] test_greeter()14*d4726bddSHONG Yifan fn test_greeter() { 15*d4726bddSHONG Yifan assert_eq!(super::greeter("Bob"), "Hello, Bob!"); 16*d4726bddSHONG Yifan } 17*d4726bddSHONG Yifan 18*d4726bddSHONG Yifan #[test] test_default_greeter()19*d4726bddSHONG Yifan fn test_default_greeter() { 20*d4726bddSHONG Yifan assert_eq!(super::default_greeter(), "Hello, world!"); 21*d4726bddSHONG Yifan } 22*d4726bddSHONG Yifan } 23