1 2 3 4 5 6 7 8 9 10 11
pub struct Rectangle { pub width: i32, pub height: i32, } impl Rectangle { // 是否包含other形状 pub fn can_hold(&self, other: &Rectangle) -> bool { self.width > other.width && self.height > other.height } }
1 2 3 4 5 6 7 8 9 10 11
pub struct Rectangle { pub width: i32, pub height: i32, } impl Rectangle { // 是否包含other形状 pub fn can_hold(&self, other: &Rectangle) -> bool { self.width > other.width && self.height > other.height } }