@@ -16,7 +16,7 @@ use any;
16
16
use cell:: { Cell , Ref , RefMut } ;
17
17
use collections:: Collection ;
18
18
use iter:: { Iterator , range} ;
19
- use kinds:: Copy ;
19
+ use kinds:: { Copy , Sized } ;
20
20
use mem;
21
21
use option:: { Option , Some , None } ;
22
22
use ops:: Deref ;
@@ -168,85 +168,85 @@ impl<'a> Show for Arguments<'a> {
168
168
/// When a format is not otherwise specified, types are formatted by ascribing
169
169
/// to this trait. There is not an explicit way of selecting this trait to be
170
170
/// used for formatting, it is only if no other format is specified.
171
- pub trait Show {
171
+ pub trait Show for Sized ? {
172
172
/// Formats the value using the given formatter.
173
173
fn fmt ( & self , & mut Formatter ) -> Result ;
174
174
}
175
175
176
176
/// Format trait for the `b` character
177
- pub trait Bool {
177
+ pub trait Bool for Sized ? {
178
178
/// Formats the value using the given formatter.
179
179
fn fmt ( & self , & mut Formatter ) -> Result ;
180
180
}
181
181
182
182
/// Format trait for the `c` character
183
- pub trait Char {
183
+ pub trait Char for Sized ? {
184
184
/// Formats the value using the given formatter.
185
185
fn fmt ( & self , & mut Formatter ) -> Result ;
186
186
}
187
187
188
188
/// Format trait for the `i` and `d` characters
189
- pub trait Signed {
189
+ pub trait Signed for Sized ? {
190
190
/// Formats the value using the given formatter.
191
191
fn fmt ( & self , & mut Formatter ) -> Result ;
192
192
}
193
193
194
194
/// Format trait for the `u` character
195
- pub trait Unsigned {
195
+ pub trait Unsigned for Sized ? {
196
196
/// Formats the value using the given formatter.
197
197
fn fmt ( & self , & mut Formatter ) -> Result ;
198
198
}
199
199
200
200
/// Format trait for the `o` character
201
- pub trait Octal {
201
+ pub trait Octal for Sized ? {
202
202
/// Formats the value using the given formatter.
203
203
fn fmt ( & self , & mut Formatter ) -> Result ;
204
204
}
205
205
206
206
/// Format trait for the `t` character
207
- pub trait Binary {
207
+ pub trait Binary for Sized ? {
208
208
/// Formats the value using the given formatter.
209
209
fn fmt ( & self , & mut Formatter ) -> Result ;
210
210
}
211
211
212
212
/// Format trait for the `x` character
213
- pub trait LowerHex {
213
+ pub trait LowerHex for Sized ? {
214
214
/// Formats the value using the given formatter.
215
215
fn fmt ( & self , & mut Formatter ) -> Result ;
216
216
}
217
217
218
218
/// Format trait for the `X` character
219
- pub trait UpperHex {
219
+ pub trait UpperHex for Sized ? {
220
220
/// Formats the value using the given formatter.
221
221
fn fmt ( & self , & mut Formatter ) -> Result ;
222
222
}
223
223
224
224
/// Format trait for the `s` character
225
- pub trait String {
225
+ pub trait String for Sized ? {
226
226
/// Formats the value using the given formatter.
227
227
fn fmt ( & self , & mut Formatter ) -> Result ;
228
228
}
229
229
230
230
/// Format trait for the `p` character
231
- pub trait Pointer {
231
+ pub trait Pointer for Sized ? {
232
232
/// Formats the value using the given formatter.
233
233
fn fmt ( & self , & mut Formatter ) -> Result ;
234
234
}
235
235
236
236
/// Format trait for the `f` character
237
- pub trait Float {
237
+ pub trait Float for Sized ? {
238
238
/// Formats the value using the given formatter.
239
239
fn fmt ( & self , & mut Formatter ) -> Result ;
240
240
}
241
241
242
242
/// Format trait for the `e` character
243
- pub trait LowerExp {
243
+ pub trait LowerExp for Sized ? {
244
244
/// Formats the value using the given formatter.
245
245
fn fmt ( & self , & mut Formatter ) -> Result ;
246
246
}
247
247
248
248
/// Format trait for the `E` character
249
- pub trait UpperExp {
249
+ pub trait UpperExp for Sized ? {
250
250
/// Formats the value using the given formatter.
251
251
fn fmt ( & self , & mut Formatter ) -> Result ;
252
252
}
@@ -257,7 +257,7 @@ macro_rules! uniform_fn_call_workaround {
257
257
( $( $name: ident, $trait_: ident; ) * ) => {
258
258
$(
259
259
#[ doc( hidden) ]
260
- pub fn $name<T : $trait_>( x: & T , fmt: & mut Formatter ) -> Result {
260
+ pub fn $name<Sized ? T : $trait_>( x: & T , fmt: & mut Formatter ) -> Result {
261
261
x. fmt( fmt)
262
262
}
263
263
) *
@@ -583,10 +583,10 @@ pub fn argumentuint<'a>(s: &'a uint) -> Argument<'a> {
583
583
584
584
// Implementations of the core formatting traits
585
585
586
- impl < ' a , T : Show > Show for & ' a T {
586
+ impl < ' a , Sized ? T : Show > Show for & ' a T {
587
587
fn fmt ( & self , f : & mut Formatter ) -> Result { secret_show ( * self , f) }
588
588
}
589
- impl < ' a , T : Show > Show for & ' a mut T {
589
+ impl < ' a , Sized ? T : Show > Show for & ' a mut T {
590
590
fn fmt ( & self , f : & mut Formatter ) -> Result { secret_show ( & * * self , f) }
591
591
}
592
592
impl < ' a > Show for & ' a Show +' a {
@@ -599,12 +599,18 @@ impl Bool for bool {
599
599
}
600
600
}
601
601
602
- impl < ' a , T : str:: Str > String for T {
602
+ impl < T : str:: Str > String for T {
603
603
fn fmt ( & self , f : & mut Formatter ) -> Result {
604
604
f. pad ( self . as_slice ( ) )
605
605
}
606
606
}
607
607
608
+ impl String for str {
609
+ fn fmt ( & self , f : & mut Formatter ) -> Result {
610
+ f. pad ( self )
611
+ }
612
+ }
613
+
608
614
impl Char for char {
609
615
fn fmt ( & self , f : & mut Formatter ) -> Result {
610
616
use char:: Char ;
@@ -708,13 +714,13 @@ floating!(f64)
708
714
// Implementation of Show for various core types
709
715
710
716
macro_rules! delegate( ( $ty: ty to $other: ident) => {
711
- impl < ' a> Show for $ty {
717
+ impl Show for $ty {
712
718
fn fmt( & self , f: & mut Formatter ) -> Result {
713
719
( concat_idents!( secret_, $other) ( self , f) )
714
720
}
715
721
}
716
722
} )
717
- delegate ! ( & ' a str to string)
723
+ delegate ! ( str to string)
718
724
delegate ! ( bool to bool )
719
725
delegate ! ( char to char )
720
726
delegate ! ( f32 to float)
@@ -761,7 +767,7 @@ impl<'a> Show for &'a any::Any+'a {
761
767
fn fmt ( & self , f : & mut Formatter ) -> Result { f. pad ( "&Any" ) }
762
768
}
763
769
764
- impl < ' a , T : Show > Show for & ' a [ T ] {
770
+ impl < T : Show > Show for [ T ] {
765
771
fn fmt ( & self , f : & mut Formatter ) -> Result {
766
772
if f. flags & ( 1 << ( rt:: FlagAlternate as uint ) ) == 0 {
767
773
try!( write ! ( f, "[" ) ) ;
@@ -782,12 +788,6 @@ impl<'a, T: Show> Show for &'a [T] {
782
788
}
783
789
}
784
790
785
- impl < ' a , T : Show > Show for & ' a mut [ T ] {
786
- fn fmt ( & self , f : & mut Formatter ) -> Result {
787
- secret_show ( & self . as_slice ( ) , f)
788
- }
789
- }
790
-
791
791
impl Show for ( ) {
792
792
fn fmt ( & self , f : & mut Formatter ) -> Result {
793
793
f. pad ( "()" )
0 commit comments