Skip to content
Snippets Groups Projects
Commit db021a4f authored by Dominik George's avatar Dominik George
Browse files

Implement From/Into for Contact enum

parent ca456792
Branches
No related tags found
No related merge requests found
......@@ -15,8 +15,7 @@ fn main() {
let addressbook: Vec<Contact> = vec![
Contact::Person(nik),
Contact::Organisation(velocitux),
nik.into(), velocitux.into(),
];
for contact in addressbook.iter() {
......
......@@ -60,3 +60,18 @@ impl fmt::Display for Contact {
}
}
}
// Contact.from(person)
// let contact: Contact = Person.into()
impl From<Person> for Contact {
fn from(value: Person) -> Self {
Self::Person(value)
}
}
impl From<Organisation> for Contact {
fn from(value: Organisation) -> Self {
Self::Organisation(value)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment