summaryrefslogtreecommitdiff
path: root/meap/ch4/src
diff options
context:
space:
mode:
authorAdam Carpenter <gitlab@53hor.net>2019-07-09 15:14:04 -0400
committerAdam Carpenter <gitlab@53hor.net>2019-07-09 15:14:04 -0400
commit7e8ee5ed9cad6484e9f13f81731b102ced58402e (patch)
tree5395402ab07bbb5a659dbd68c701e22a1227202f /meap/ch4/src
downloadlearning-rust-7e8ee5ed9cad6484e9f13f81731b102ced58402e.tar.xz
learning-rust-7e8ee5ed9cad6484e9f13f81731b102ced58402e.zip
Init.
Diffstat (limited to 'meap/ch4/src')
-rwxr-xr-xmeap/ch4/src/main.rs106
1 files changed, 106 insertions, 0 deletions
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<Message> {
+// 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<Message>,
+//}
+//
+//impl Mailbox {
+// fn post(&mut self, msg: Message) {
+// self.messages.push(msg);
+// }
+//
+// fn deliver(&mut self, recipient: &CubeSat) -> Option<Message> {
+// 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<u64> {
+// 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<GroundStation> = Rc::new(GroundStation {});
+ dbg!(base);
+}