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