-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation about the dbg! macro #1658
Comments
A lot of our printlns would be |
As a new rust user I really like |
Sure, once we switch to 1.32 i'd be up for it. We're currently on 1.31. |
since there is code that need 1.32 or newer (#2034) I think the title page should be updated and |
Just realized that because dbg! takes ownership, instead of having to explain |
It can be used on copy types without that. Or save |
@carols10cents fn main() {
let s = dbg!("abc".to_owned());
let s = dbg!(s);
drop(s);
} Or even fn main() {
if "42" == dbg!(answer.get()) {
println!("The answer is 42");
}
} Copy types always work (as @dekellum sayed) |
@rusty-snake yes, I read the 2 RFCs and the tracking issue before commenting here. I understand the justification behind the |
Isn't there intrinsic value to the reader and early learner, to see both |
@dekellum the issue is that closing this issue is not just a quick find-and-replace |
Fair enough, I still think it has intrinsic value, as early learners will soon encounter both in the wild, and print debugging is rather fundamental. |
I've been going thru the book, as a newbie, and was already thinking that printing debug info wouldn't be as fun as I'd like. Then I just ran across I thing getting at least a mention of it in the documentation is a great idea. We don't have to switch everything to use it in a few places and then later start using it more after |
Ok, I just added an explanation of |
Update books ## nomicon 2 commits in f51734eb5566c826b471977747ea3d7d6915bbe9..0c7e5bd1428e7838252bb57b7f0fbfda4ec82f02 2021-07-23 18:24:35 +0900 to 2021-08-04 10:18:22 -0700 - Document lifetime elision for fn types, Fn*, impl (rust-lang/nomicon#298) - Remove unnecessary `extern crate`s (rust-lang/nomicon#297) ## reference 3 commits in 3b7be075af5d6e402a18efff672a8a265b4596fd..4884fe45c14f8b22121760fb117181bb4da8dfe0 2021-07-26 13:20:11 -0700 to 2021-07-28 21:31:28 -0700 - Mention "function item type to `fn pointer`" coercion (rust-lang/reference#1079) - example for bindings after at (rust-lang/reference#1027) - array-expr.md: fix typo; 'polish' sentence (rust-lang/reference#1080) ## book 10 commits in a07036f864b37896b31eb996cd7aedb489f69a1f..7e49659102f0977d9142190e1ba23345c0f00eb1 2021-07-26 20:19:46 -0400 to 2021-08-03 21:41:35 -0400 - Make explicit that enum variant construction is a function - Clarify why None means we have to annotate the type - Make the convert quotes script able to do one chapter - Snapshot of chapter 5 - (rust-lang/book#2811) - (rust-lang/book#2809) - Ugh quote script, that's not right - Introduce the dbg macro. Connects to rust-lang/book#1658 - Add an example of declaring and instantiating unit-like structs. Fixes rust-lang/book#2442. - Remove authors field from all the manifests (rust-lang/book#2805) ## rustc-dev-guide 5 commits in 09343d6..c4644b4 2021-07-26 00:37:28 +0200 to 2021-08-10 20:41:44 +0900 - Remove a dead link in `new-target.md` + other nits (rust-lang/rustc-dev-guide#1186) - Add description of -opt-bisect-limit LLVM option (rust-lang/rustc-dev-guide#1182) - Fixed team responsible for stabilization (rust-lang/rustc-dev-guide#1181) - Add S-Inactive PRs as another source of things contributors could work on (rust-lang/rustc-dev-guide#1177) - git.md: Fix No-Merge Policy link ## embedded-book 1 commits in 09986cd352404eb4659db44613b27cac9aa652fc..4f9fcaa30d11ba52b641e6fd5206536d65838af9 2021-07-18 19:26:46 +0000 to 2021-08-06 17:43:12 +0000 - Fix typo in 'Memory Mapped Registers' (rust-embedded/book#298)
Update books ## nomicon 2 commits in f51734eb5566c826b471977747ea3d7d6915bbe9..0c7e5bd1428e7838252bb57b7f0fbfda4ec82f02 2021-07-23 18:24:35 +0900 to 2021-08-04 10:18:22 -0700 - Document lifetime elision for fn types, Fn*, impl (rust-lang/nomicon#298) - Remove unnecessary `extern crate`s (rust-lang/nomicon#297) ## reference 3 commits in 3b7be075af5d6e402a18efff672a8a265b4596fd..4884fe45c14f8b22121760fb117181bb4da8dfe0 2021-07-26 13:20:11 -0700 to 2021-07-28 21:31:28 -0700 - Mention "function item type to `fn pointer`" coercion (rust-lang/reference#1079) - example for bindings after at (rust-lang/reference#1027) - array-expr.md: fix typo; 'polish' sentence (rust-lang/reference#1080) ## book 10 commits in a07036f864b37896b31eb996cd7aedb489f69a1f..7e49659102f0977d9142190e1ba23345c0f00eb1 2021-07-26 20:19:46 -0400 to 2021-08-03 21:41:35 -0400 - Make explicit that enum variant construction is a function - Clarify why None means we have to annotate the type - Make the convert quotes script able to do one chapter - Snapshot of chapter 5 - (rust-lang/book#2811) - (rust-lang/book#2809) - Ugh quote script, that's not right - Introduce the dbg macro. Connects to rust-lang/book#1658 - Add an example of declaring and instantiating unit-like structs. Fixes rust-lang/book#2442. - Remove authors field from all the manifests (rust-lang/book#2805) ## rustc-dev-guide 5 commits in 09343d6..c4644b4 2021-07-26 00:37:28 +0200 to 2021-08-10 20:41:44 +0900 - Remove a dead link in `new-target.md` + other nits (rust-lang/rustc-dev-guide#1186) - Add description of -opt-bisect-limit LLVM option (rust-lang/rustc-dev-guide#1182) - Fixed team responsible for stabilization (rust-lang/rustc-dev-guide#1181) - Add S-Inactive PRs as another source of things contributors could work on (rust-lang/rustc-dev-guide#1177) - git.md: Fix No-Merge Policy link ## embedded-book 1 commits in 09986cd352404eb4659db44613b27cac9aa652fc..4f9fcaa30d11ba52b641e6fd5206536d65838af9 2021-07-18 19:26:46 +0000 to 2021-08-06 17:43:12 +0000 - Fix typo in 'Memory Mapped Registers' (rust-embedded/book#298)
Update books ## nomicon 2 commits in f51734eb5566c826b471977747ea3d7d6915bbe9..0c7e5bd1428e7838252bb57b7f0fbfda4ec82f02 2021-07-23 18:24:35 +0900 to 2021-08-04 10:18:22 -0700 - Document lifetime elision for fn types, Fn*, impl (rust-lang/nomicon#298) - Remove unnecessary `extern crate`s (rust-lang/nomicon#297) ## reference 3 commits in 3b7be075af5d6e402a18efff672a8a265b4596fd..4884fe45c14f8b22121760fb117181bb4da8dfe0 2021-07-26 13:20:11 -0700 to 2021-07-28 21:31:28 -0700 - Mention "function item type to `fn pointer`" coercion (rust-lang/reference#1079) - example for bindings after at (rust-lang/reference#1027) - array-expr.md: fix typo; 'polish' sentence (rust-lang/reference#1080) ## book 10 commits in a07036f864b37896b31eb996cd7aedb489f69a1f..7e49659102f0977d9142190e1ba23345c0f00eb1 2021-07-26 20:19:46 -0400 to 2021-08-03 21:41:35 -0400 - Make explicit that enum variant construction is a function - Clarify why None means we have to annotate the type - Make the convert quotes script able to do one chapter - Snapshot of chapter 5 - (rust-lang/book#2811) - (rust-lang/book#2809) - Ugh quote script, that's not right - Introduce the dbg macro. Connects to rust-lang/book#1658 - Add an example of declaring and instantiating unit-like structs. Fixes rust-lang/book#2442. - Remove authors field from all the manifests (rust-lang/book#2805) ## rustc-dev-guide 5 commits in 09343d6..c4644b4 2021-07-26 00:37:28 +0200 to 2021-08-10 20:41:44 +0900 - Remove a dead link in `new-target.md` + other nits (rust-lang/rustc-dev-guide#1186) - Add description of -opt-bisect-limit LLVM option (rust-lang/rustc-dev-guide#1182) - Fixed team responsible for stabilization (rust-lang/rustc-dev-guide#1181) - Add S-Inactive PRs as another source of things contributors could work on (rust-lang/rustc-dev-guide#1177) - git.md: Fix No-Merge Policy link ## embedded-book 1 commits in 09986cd352404eb4659db44613b27cac9aa652fc..4f9fcaa30d11ba52b641e6fd5206536d65838af9 2021-07-18 19:26:46 +0000 to 2021-08-06 17:43:12 +0000 - Fix typo in 'Memory Mapped Registers' (rust-embedded/book#298)
Opened #2842 to address most of what I saw as direct swaps from |
The
dbg!
macro was just stabilized and will be in Rust 1.32 (see rust-lang/rust#54306). Since one important reason for introducing the macro in the first place was to help beginners it might make sense to use it in the book.The text was updated successfully, but these errors were encountered: