From 7e8ee5ed9cad6484e9f13f81731b102ced58402e Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Tue, 9 Jul 2019 15:14:04 -0400 Subject: Init. --- meap/ch4/src/main.rs | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100755 meap/ch4/src/main.rs (limited to 'meap/ch4/src') diff --git a/meap/ch4/src/main.rs b/meap/ch4/src/main.rs new file mode 100755 index 0000000..fd00fef --- /dev/null +++ b/meap/ch4/src/main.rs @@ -0,0 +1,106 @@ +//#[derive(Debug, Clone, Copy)] +//struct CubeSat { +// id: u64, +//} +// +//impl CubeSat { +// fn recv(&self, mailbox: &mut Mailbox) -> Option { +// mailbox.deliver(&self) +// } +//} +// +////impl Copy for CubeSat {} +//// +////impl Clone for CubeSat { +//// fn clone(&self) -> Self { +//// CubeSat { +//// id: self.id, +//// } +//// } +////} +// +//#[derive(Debug, Clone, Copy)] +//enum StatusMessage { +// Ok, +//} +// +////impl Copy for StatusMessage {} +//// +////impl Clone for StatusMessage { +//// fn clone(&self) -> Self { +//// *self +//// } +////} +// +//#[derive(Debug)] +//struct Mailbox { +// messages: Vec, +//} +// +//impl Mailbox { +// fn post(&mut self, msg: Message) { +// self.messages.push(msg); +// } +// +// fn deliver(&mut self, recipient: &CubeSat) -> Option { +// for i in 0..self.messages.len() { +// if self.messages[i].to == recipient.id { +// let msg = self.messages.remove(i); +// return Some(msg); +// } +// } +// +// None +// } +//} +// +//struct GroundStation {} +// +//impl GroundStation { +// fn send(&self, mailbox: &mut Mailbox, msg: Message) { +// mailbox.post(msg); +// } +// +// fn connect(&self, sat_id: u64) -> CubeSat { +// CubeSat { +// id: sat_id, +// } +// } +//} +// +//#[derive(Debug)] +//struct Message { +// to: u64, +// content: String, +//} +// +//fn check_status(sat_id: CubeSat) -> StatusMessage { +// StatusMessage::Ok +//} +// +//fn fetch_sat_ids() -> Vec { +// vec![1, 2, 3] +//} +// +//fn main() { +// let sat_a = CubeSat { +// id: 0, +// }; +// +// let a_status = check_status(sat_a.clone()); +// println!("a: {:?}", a_status); +// +// let a_status = check_status(sat_a.clone()); +// println!("a: {:?}", a_status); +//} +// + +use std::rc::Rc; + +#[derive(Debug)] +struct GroundStation {} + +fn main() { + let base: Rc = Rc::new(GroundStation {}); + dbg!(base); +} -- cgit v1.2.3