File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 4f29814f2a2503f9abb2ccb1e3c286dbf8e8a0d0
2
+ refs/heads/master: 88877effa8661d20e285aa82a4a5015a4a4c871c
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5
5
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
Original file line number Diff line number Diff line change @@ -312,15 +312,15 @@ mod rt {
312
312
let mut s = str:: from_char ( c) ;
313
313
ret pad( cv, s, pad_nozero) ;
314
314
}
315
- fn conv_str ( cv : conv , s : ~ str ) -> ~str {
315
+ fn conv_str ( cv : conv , s : & str ) -> ~str {
316
316
// For strings, precision is the maximum characters
317
317
// displayed
318
318
let mut unpadded = alt cv. precision {
319
- count_implied { s }
319
+ count_implied { s. to_unique ( ) }
320
320
count_is ( max) {
321
321
if max as uint < str:: char_len ( s ) {
322
322
str:: substr ( s, 0 u, max as uint )
323
- } else { s }
323
+ } else { s. to_unique ( ) }
324
324
}
325
325
} ;
326
326
ret pad( cv, unpadded, pad_nozero) ;
@@ -433,6 +433,14 @@ mod rt {
433
433
}
434
434
}
435
435
436
+ #[ cfg( test) ]
437
+ mod test {
438
+ #[ test]
439
+ fn fmt_slice ( ) {
440
+ let s = "abc" ;
441
+ let _s = #fmt ( "%s" , s) ;
442
+ }
443
+ }
436
444
437
445
// Local Variables:
438
446
// mode: rust;
Original file line number Diff line number Diff line change @@ -1944,6 +1944,7 @@ trait str_slice {
1944
1944
fn to_upper ( ) -> ~str ;
1945
1945
fn escape_default ( ) -> ~str ;
1946
1946
fn escape_unicode ( ) -> ~str ;
1947
+ fn to_unique ( ) -> ~str ;
1947
1948
}
1948
1949
1949
1950
/// Extension methods for strings
@@ -2050,6 +2051,9 @@ impl extensions/& of str_slice for &str {
2050
2051
/// Escape each char in `s` with char::escape_unicode.
2051
2052
#[ inline]
2052
2053
fn escape_unicode ( ) -> ~str { escape_unicode ( self ) }
2054
+
2055
+ #[ inline]
2056
+ fn to_unique ( ) -> ~str { self . slice ( 0 , self . len ( ) ) }
2053
2057
}
2054
2058
2055
2059
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments