summaryrefslogtreecommitdiff
path: root/ex3_1/src/main.rs
blob: af72ecbc0a0e825fb04fb1583510af6a09299a51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);
    }
}