File tree 1 file changed +20
-2
lines changed
1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -1179,10 +1179,28 @@ impl PartialEq for ParseError {
1179
1179
#[ stable( feature = "str_parse_error" , since = "1.5.0" ) ]
1180
1180
impl Eq for ParseError { }
1181
1181
1182
- /// A generic trait for converting a value to a string
1182
+ /// A trait for converting a value to a `String`.
1183
+ ///
1184
+ /// This trait is automatically implemented for any type which implements the
1185
+ /// [`Display`] trait. As such, `ToString` shouldn't be implemented directly:
1186
+ /// [`Display`] should be implemented instead, and you get the `ToString`
1187
+ /// implementation for free.
1188
+ ///
1189
+ /// [`Display`]: ../fmt/trait.Display.html
1183
1190
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1184
1191
pub trait ToString {
1185
- /// Converts the value of `self` to an owned string
1192
+ /// Converts the given value to a `String`.
1193
+ ///
1194
+ /// # Examples
1195
+ ///
1196
+ /// Basic usage:
1197
+ ///
1198
+ /// ```
1199
+ /// let i = 5;
1200
+ /// let five = String::from("5");
1201
+ ///
1202
+ /// assert_eq!(five, i.to_string());
1203
+ /// ```
1186
1204
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1187
1205
fn to_string ( & self ) -> String ;
1188
1206
}
You can’t perform that action at this time.
0 commit comments