rust-cookbook icon indicating copy to clipboard operation
rust-cookbook copied to clipboard

Recipe: Implement Display, Debug for custom type

Open AndyGauge opened this issue 7 years ago • 2 comments
trafficstars

Crates std
Section 16.2 String Parsing

Given a simple custom type, implement debug and display directly. Do not lean on derive. Similar to this: https://doc.rust-lang.org/1.6.0/std/fmt/trait.Display.html#examples

It is OK for the cookbook to have similar examples to other sources, as this may be the first place someone looks to solve this problem. Do not use an x,y point as the example though. Mixed data types would be ideal.

Let's throw Hash on the sample too.

AndyGauge avatar Apr 24 '18 17:04 AndyGauge

I'll take this one if it isn't claimed!

plauche avatar Jun 15 '18 23:06 plauche

Would you like a simple implementation, or would you like to also see some of extra formatter flags used?

plauche avatar Jun 18 '18 15:06 plauche