July 12, 2018

关于我

struct Me<'a> {
    name: &'a str,
    email: &'a str,
    skills: Vec<&'a str>,
    identify: &'a Developer<'a>,
    github: &'a str,
    location: &'a City<'a>,
}
impl<'a> Me<'a> {
    fn contact(self) -> String {
        format!("please send email to {}", self.email)
    }
}
struct Developer<'a> { company: &'a str }
struct City<'a> { c: &'a str }
impl<'a> City<'a> {
    fn from(city: &'a str) -> City {
        City { c: city }
    }
    fn to(self, city: &'a str) -> City {
        City { c: city }
    }
}

fn main() {
    let me = Me {
        name: "Kilerd Chan",
        email: "blove694@gmail.com",
        skills: vec!["Python", "Rust", "React"],
        identify: &Developer{ company: "ThoughtWorks" },
        github: "https://github.com/kilerd",
        location: &City::from("Guangzhou").to("Shenzhen"),
    };
    
    println!("{}", me.contact());
    
}