mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-02-13 16:32:23 +02:00
Added an Alternative way for printing struct and declaring a string. (#1773)
Knowing to_string method is good for learner to use at some situation. Knowing print complete struct object can be useful while debug. --------- Co-authored-by: Dustin J. Mitchell <djmitche@google.com>
This commit is contained in:
parent
a673efbc14
commit
faea6894e7
@ -54,5 +54,10 @@ all `str` methods on a `String`.
|
||||
out-of-bounds.
|
||||
- To a substring by using `s3[0..4]`, where that slice is on character
|
||||
boundaries or not.
|
||||
- Many types can be converted to a string with the
|
||||
[`to_string`](https://doc.rust-lang.org/std/string/trait.ToString.html#tymethod.to_string)
|
||||
method. This trait is automatically implemented for all types that implement
|
||||
`Display`, so anything that can be formatted can also be converted to a
|
||||
string.
|
||||
|
||||
</details>
|
||||
|
@ -53,4 +53,7 @@ later, but this is enough for subsequent slides and exercises to use strings.
|
||||
}
|
||||
```
|
||||
|
||||
- Using `{:?}` is a convenient way to print array/vector/struct of values for
|
||||
debugging purposes, and it's commonly used in code.
|
||||
|
||||
</details>
|
||||
|
Loading…
x
Reference in New Issue
Block a user