-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce the dbg macro. Connects to #1658
- Loading branch information
1 parent
79085eb
commit 5813399
Showing
5 changed files
with
79 additions
and
7 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/Cargo.lock
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "rectangles" | ||
version = "0.1.0" | ||
edition = "2018" | ||
|
||
[dependencies] |
9 changes: 9 additions & 0 deletions
9
listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$ cargo run | ||
Compiling rectangles v0.1.0 (file:///projects/rectangles) | ||
Finished dev [unoptimized + debuginfo] target(s) in 0.61s | ||
Running `target/debug/rectangles` | ||
[src/main.rs:10] 30 * scale = 60 | ||
[src/main.rs:14] &rect1 = Rectangle { | ||
width: 60, | ||
height: 50, | ||
} |
15 changes: 15 additions & 0 deletions
15
listings/ch05-using-structs-to-structure-related-data/no-listing-05-dbg-macro/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#[derive(Debug)] | ||
struct Rectangle { | ||
width: u32, | ||
height: u32, | ||
} | ||
|
||
fn main() { | ||
let scale = 2; | ||
let rect1 = Rectangle { | ||
width: dbg!(30 * scale), | ||
height: 50, | ||
}; | ||
|
||
dbg!(&rect1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters