Skip to content

Commit 22fdebd

Browse files
Mention to_string()
1 parent 96a17ef commit 22fdebd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/language/strings.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ let person = Person {
162162
println!("{person}");
163163
```
164164

165+
For converting values to string using `Display` without formatting, you can use
166+
the `std::string::ToString` trait. Its `to_string()` method is equal to the `ToString()`
167+
method in .NET, and implemented automatically whenever you implement `Display`.
168+
165169
Another option is to use the `std::fmt::Debug` trait. The `Debug` trait is
166170
implemented for all standard types and can be used to print the internal
167171
representation of a type. The following example shows how to use the `derive`

0 commit comments

Comments
 (0)