Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bb522d1

Browse files
git commit
1 parent 79093b1 commit bb522d1

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed
510 KB
Binary file not shown.

‎5. Compound Data Types/5.5 Structs/structs7.rs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,21 @@ fn main() {
1919
println!(__, rect1); // Print debug info to stdout
2020
}
2121
*/
22+
23+
#[derive(Debug)]
24+
struct Rectangle {
25+
width: u32,
26+
height: u32,
27+
}
28+
29+
fn main() {
30+
let scale = 2;
31+
let rect1 = Rectangle {
32+
width: dbg!(30 * scale), // Print debug info to stderr and assign the value of `30 * scale` to `width`
33+
height: 50,
34+
};
35+
36+
dbg!(&rect1); // Print debug info to stderr
37+
38+
println!("{:?}", rect1); // Print debug info to stdout
39+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#[derive(Debug)]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /