Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unused)] | |
use std::collections::HashMap; | |
use std::io; | |
struct PhoneEntry { | |
name: String, | |
phone: String, | |
} | |
impl PhoneEntry { | |
fn new(self, name: String, phone: String) -> PhoneEntry { | |
PhoneEntry { name, phone } | |
} | |
} | |
struct PhoneBook { | |
phone_book: HashMap<String, PhoneEntry>, | |
} | |
impl PhoneBook { | |
fn add_contact(self) { | |
let mut name = String::new(); | |
let mut phone = String::new(); | |
io::stdin().read_line(&mut name).unwrap(); | |
} | |
} | |
fn main() { | |
let mut pb = PhoneBook { | |
phone_book: HashMap::new(), | |
}; | |
pb.add_contact(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment