// Code is in the preload fn person_builder(first_name: &str, last_name: &str) -> Person { Person { first_name: String::from(first_name), last_name: String::from(last_name) } }
- // Code is in the preload
fn person_builder(first_name:&'static str, last_name: &'static str) -> Person {Person { first_name: first_name, last_name: last_name }- fn person_builder(first_name: &str, last_name: &str) -> Person {
- Person { first_name: String::from(first_name), last_name: String::from(last_name) }
- }
#[test] fn can_build_a_person() { let p = person_builder("Jimbo", "Jones"); assert_eq!(p.greet(), "Hello, my name is Jimbo Jones"); } #[test] #[should_panic] fn failed_name() { let p = person_builder("Bill", "Smith"); assert_eq!(&p.first_name, "Frank"); }
- #[test]
- fn can_build_a_person() {
- let p = person_builder("Jimbo", "Jones");
- assert_eq!(p.greet(), "Hello, my name is Jimbo Jones");
- }
- #[test]
- #[should_panic]
- fn failed_name() {
- let p = person_builder("Bill", "Smith");
assert_eq!(p.first_name, "Frank");- assert_eq!(&p.first_name, "Frank");
- }