rust-exercises/rectangles/src/main.rs

19 lines
258 B
Rust
Raw Normal View History

#[derive(Debug)]
struct Rectangle {
width: u32,
height: u32,
}
2024-11-27 22:39:46 +00:00
impl Rectangle {
2024-11-27 23:12:32 +00:00
fn square(size: u32) -> Self {
Self {
width: size,
height: size,
}
2024-11-27 23:03:49 +00:00
}
2024-11-27 22:39:46 +00:00
}
fn main() {
2024-11-27 23:12:32 +00:00
let sq = Rectangle::square(3);
}