面试题答案
一键面试struct Rectangle {
width: u32,
height: u32,
}
impl Rectangle {
fn new(width: u32, height: u32) -> Option<Rectangle> {
if width > 0 && height > 0 {
Some(Rectangle { width, height })
} else {
None
}
}
}