Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created January 24, 2020 16:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/7dac0d228d9f731cc285ad609d968a2b to your computer and use it in GitHub Desktop.
Save rust-play/7dac0d228d9f731cc285ad609d968a2b to your computer and use it in GitHub Desktop.
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