File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed
branches/dist-snap/src/libcore Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9
9
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10
- refs/heads/dist-snap: 4f29814f2a2503f9abb2ccb1e3c286dbf8e8a0d0
10
+ refs/heads/dist-snap: 88877effa8661d20e285aa82a4a5015a4a4c871c
11
11
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
12
12
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
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