]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #7204 : alexcrichton/rust/deriving-to-string, r=pcwalton
authorbors <bors@rust-lang.org>
Sun, 23 Jun 2013 00:13:51 +0000 (17:13 -0700)
committerbors <bors@rust-lang.org>
Sun, 23 Jun 2013 00:13:51 +0000 (17:13 -0700)
Closes #7180 and #7179.

Before, the `deriving(ToStr)` attribute was essentially `fmt!("%?")`. This changes it to recursively invoke `to_str()` on fields instead of relying on `fmt!`-style things. This seems more natural to me and what should actually be expected.

1  2 
doc/rust.md

diff --cc doc/rust.md
index f533bb50f7515cc911925927e9f896016859d904,4eedcb9a9520264f1a3e845d175bb8a21e2aa58c..3dc70ed10c770b854c9eb9f3162bc8acc94800c6
@@@ -1561,9 -1561,10 +1561,11 @@@ Supported traits for `deriving` are
  * `Clone` and `DeepClone`, to perform (deep) copies.
  * `IterBytes`, to iterate over the bytes in a data type.
  * `Rand`, to create a random instance of a data type.
 +* `Zero`, to create an zero (or empty) instance of a data type.
  * `ToStr`, to convert to a string. For a type with this instance,
-   `obj.to_str()` has the same output as `fmt!("%?", obj)`.
+   `obj.to_str()` has similar output as `fmt!("%?", obj)`, but it differs in that
+   each constituent field of the type must also implement `ToStr` and will have
+   `field.to_str()` invoked to build up the result.
  
  # Statements and expressions