File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 48
48
#![ feature( placement_new_protocol) ]
49
49
#![ feature( shared) ]
50
50
#![ feature( slice_patterns) ]
51
+ #![ feature( specialization) ]
51
52
#![ feature( staged_api) ]
52
53
#![ feature( step_by) ]
53
54
#![ feature( str_char) ]
Original file line number Diff line number Diff line change @@ -1770,7 +1770,7 @@ pub trait ToString {
1770
1770
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1771
1771
impl < T : fmt:: Display + ?Sized > ToString for T {
1772
1772
#[ inline]
1773
- fn to_string ( & self ) -> String {
1773
+ default fn to_string ( & self ) -> String {
1774
1774
use core:: fmt:: Write ;
1775
1775
let mut buf = String :: new ( ) ;
1776
1776
let _ = buf. write_fmt ( format_args ! ( "{}" , self ) ) ;
@@ -1779,6 +1779,14 @@ impl<T: fmt::Display + ?Sized> ToString for T {
1779
1779
}
1780
1780
}
1781
1781
1782
+ #[ stable( feature = "str_to_string_specialization" , since = "1.9.0" ) ]
1783
+ impl ToString for str {
1784
+ #[ inline]
1785
+ fn to_string ( & self ) -> String {
1786
+ String :: from ( self )
1787
+ }
1788
+ }
1789
+
1782
1790
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1783
1791
impl AsRef < str > for String {
1784
1792
#[ inline]
You can’t perform that action at this time.
0 commit comments