Skip to content
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

Formatted print - fmt::Display example issue #1824

Open
Calm0016 opened this issue Feb 27, 2024 · 1 comment
Open

Formatted print - fmt::Display example issue #1824

Calm0016 opened this issue Feb 27, 2024 · 1 comment

Comments

@Calm0016
Copy link

In https://doc.rust-lang.org/rust-by-example/hello/print.html

at line 47 there is an example for

// This will not compile because `Structure` does not implement
// fmt::Display.
//println!("This struct `{}` won't print...", Structure(3));
// TODO ^ Try uncommenting this line

if you uncomment the 48th, 49th, or both lines it still throws an error message.

@snailtomatoes
Copy link

The first error in the code is at line 37 and is for you to correct as first activity.

The line 47 is part of the second activity and is intended to be done after the first. It shows how Structure can't be printed by default since it's a user defined type and thus not part of fmt::Display.
The following chapters will explain how user defined types can be printed.

The line 47 should be re-commented to complete the third and final activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants