blob: a7e96546ba57577bb2b9837aee08e47a2c14cdfa (
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
30
|
#[derive(Debug, Eq, PartialEq)]
pub struct Order {
price: u32,
quantity: u32,
}
impl Order {
pub fn is_available(&self) -> bool {
self.quantity != 0
}
}
fn main() {
let o = Order{price: 1, quantity: 1};
println!("{}", o.is_available());
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);
}
}
|