mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
304 B
21 lines
304 B
3 years ago
|
#[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);
|
||
|
}
|