summaryrefslogtreecommitdiff
path: root/ex3_1/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ex3_1/src/main.rs')
-rw-r--r--ex3_1/src/main.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/ex3_1/src/main.rs b/ex3_1/src/main.rs
new file mode 100644
index 0000000..af72ecb
--- /dev/null
+++ b/ex3_1/src/main.rs
@@ -0,0 +1,29 @@
+#[derive(Debug, Eq, PartialEq)]
+pub struct Order {
+ price: u32,
+ quantity: u32,
+}
+
+impl Order {
+ pub fn is_available(self: Self) -> bool {
+ self.quantity != 0
+ }
+}
+
+fn main() {
+ let o = Order{price: 1, quantity: 1};
+ println!("{}", o.is_available());
+}
+
+#[cfg(test)]
+mod tests {
+ use crate::*;
+
+ #[test]
+ fn t0() {
+ let o1 = Order{price: 1, quantity: 1};
+ let o2: Order = Order{price: 1, quantity: 1};
+ assert_eq!(o1,o2);
+ }
+}
+