chapter 5 done
This commit is contained in:
parent
b5dec65244
commit
645a565719
@ -13,6 +13,15 @@ impl Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
impl Rectangle {
|
||||
fn square(size: u32) -> Self {
|
||||
Self {
|
||||
width: size,
|
||||
height: size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -29,5 +38,9 @@ fn main() {
|
||||
|
||||
println!("Can rect1 hold rect2? {}", rect1.can_hold(&rect2));
|
||||
println!("Can rect1 hold rect3? {}", rect1.can_hold(&rect3));
|
||||
|
||||
let sq = Rectangle::square(5);
|
||||
println!("r: {:?}", sq);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user