]> git.proxmox.com Git - rustc.git/blame - src/doc/book/listings/ch05-using-structs-to-structure-related-data/no-listing-03-associated-functions/src/main.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / doc / book / listings / ch05-using-structs-to-structure-related-data / no-listing-03-associated-functions / src / main.rs
CommitLineData
74b04a01
XL
1#[derive(Debug)]
2struct Rectangle {
3 width: u32,
4 height: u32,
5}
6
7// ANCHOR: here
8impl Rectangle {
923072b8
FG
9 fn square(size: u32) -> Self {
10 Self {
74b04a01
XL
11 width: size,
12 height: size,
13 }
14 }
15}
16// ANCHOR_END: here
17
18fn main() {
19 let sq = Rectangle::square(3);
20}