Skip to content

Commit ae546a5

Browse files
committed
---
yaml --- r: 22739 b: refs/heads/master c: 88877ef h: refs/heads/master i: 22737: a415895 22735: 58274f6 v: v3
1 parent 21c70ec commit ae546a5

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 4f29814f2a2503f9abb2ccb1e3c286dbf8e8a0d0
2+
refs/heads/master: 88877effa8661d20e285aa82a4a5015a4a4c871c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/extfmt.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,15 @@ mod rt {
312312
let mut s = str::from_char(c);
313313
ret pad(cv, s, pad_nozero);
314314
}
315-
fn conv_str(cv: conv, s: ~str) -> ~str {
315+
fn conv_str(cv: conv, s: &str) -> ~str {
316316
// For strings, precision is the maximum characters
317317
// displayed
318318
let mut unpadded = alt cv.precision {
319-
count_implied { s }
319+
count_implied { s.to_unique() }
320320
count_is(max) {
321321
if max as uint < str::char_len(s) {
322322
str::substr(s, 0u, max as uint)
323-
} else { s }
323+
} else { s.to_unique() }
324324
}
325325
};
326326
ret pad(cv, unpadded, pad_nozero);
@@ -433,6 +433,14 @@ mod rt {
433433
}
434434
}
435435

436+
#[cfg(test)]
437+
mod test {
438+
#[test]
439+
fn fmt_slice() {
440+
let s = "abc";
441+
let _s = #fmt("%s", s);
442+
}
443+
}
436444

437445
// Local Variables:
438446
// mode: rust;

trunk/src/libcore/str.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,7 @@ trait str_slice {
19441944
fn to_upper() -> ~str;
19451945
fn escape_default() -> ~str;
19461946
fn escape_unicode() -> ~str;
1947+
fn to_unique() -> ~str;
19471948
}
19481949

19491950
/// Extension methods for strings
@@ -2050,6 +2051,9 @@ impl extensions/& of str_slice for &str {
20502051
/// Escape each char in `s` with char::escape_unicode.
20512052
#[inline]
20522053
fn escape_unicode() -> ~str { escape_unicode(self) }
2054+
2055+
#[inline]
2056+
fn to_unique() -> ~str { self.slice(0, self.len()) }
20532057
}
20542058

20552059
#[cfg(test)]

0 commit comments

Comments
 (0)