mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-04-23 14:18:13 +08:00
21 lines
294 B
Rust
Executable File
21 lines
294 B
Rust
Executable File
#[derive(Debug)]
|
|
struct Rectangle {
|
|
width: u32,
|
|
height: u32,
|
|
}
|
|
|
|
// ANCHOR: here
|
|
impl Rectangle {
|
|
fn square(size: u32) -> Self {
|
|
Self {
|
|
width: size,
|
|
height: size,
|
|
}
|
|
}
|
|
}
|
|
// ANCHOR_END: here
|
|
|
|
fn main() {
|
|
let sq = Rectangle::square(3);
|
|
}
|