3

Document that `Display` entails `ToString` · Issue #92941 · rust-lang/rust · Git...

 2 years ago
source link: https://github.com/rust-lang/rust/issues/92941
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

steffahn commented on Jan 15

edited by rustbot

I just answered a question on URLO about when to implement or not to implement Display, and I noticed that the docs on the Display trait are lacking.

In particular, I believe they should definitely point out that implementing Display will give a type a .to_string() method via the ToString trait. This is important to keep in mind when you’re designing an API; it’s also the reason why in the standard library Path doesn’t implement Display directly (but offers a .display() method): because converting Path to String is lossy or fallible, and an (implicitly) lossy to_string method would not fit the API.

@rustbot label A-docs, C-enhancement, T-libs-api


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK