Skip to content

Update print.md #1663

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

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/hello/print.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn main() {
// Only types that implement fmt::Display can be formatted with `{}`. User-
// defined types do not implement fmt::Display by default.

#[allow(dead_code)]
#[allow(dead_code)] // disable `dead_code` which warn against unused module
struct Structure(i32);

// This will not compile because `Structure` does not implement
Expand Down Expand Up @@ -89,6 +89,8 @@ for these types. To print text for custom types, more steps are required.
Implementing the `fmt::Display` trait automatically implements the
[`ToString`] trait which allows us to [convert] the type to [`String`][string].

In *line 46*, `#[allow(dead_code)]` is an [attribute] which only apply to the module after it.

### Activities

* Fix the issue in the above code (see FIXME) so that it runs without
Expand All @@ -102,8 +104,7 @@ Implementing the `fmt::Display` trait automatically implements the

### See also:

[`std::fmt`][fmt], [`macros`][macros], [`struct`][structs],
and [`traits`][traits]
[`std::fmt`][fmt], [`macros`][macros], [`struct`][structs], [`traits`][traits], and [`dead_code`][dead_code]

[fmt]: https://doc.rust-lang.org/std/fmt/
[macros]: ../macros.md
Expand All @@ -112,3 +113,5 @@ and [`traits`][traits]
[traits]: https://doc.rust-lang.org/std/fmt/#formatting-traits
[`ToString`]: https://doc.rust-lang.org/std/string/trait.ToString.html
[convert]: ../conversion/string.md
[attribute]: ../attribute.md
[dead_code]: ../attribute/unused.md