Slide 18
Slide 18 text
Checking Results with the assert! (2/5)
1 #[derive(Debug)]
2 pub struct Rectangle {
3 length: u32,
4 width: u32,
5 }
6
7 impl Rectangle {
8 pub fn can_hold(&self, other: &Rectangle) -> bool {
9 self.length > other.length && self.width > other.width
10 }
11 }
can_hold() ϝιου
ϒʔϧΛฦ͢
→ assert! Ͱͷςετʹ࠷ద!!
length ͕ 8 , width ͕ 7 ͷ Rectangle ͕
length ͕ 5 , width ͕ 1 ͷ Rectangle Λ hold Ͱ
͖ΔࣄΛςετ
Katsuki Kobayashi RustBook ษڧձ