Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code shared from the Rust Playground
#![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
You can’t perform that action at this time.