Skip to content

Commit b79c7d9

Browse files
committed
---
yaml --- r: 20631 b: refs/heads/snap-stage3 c: 88877ef h: refs/heads/master i: 20629: b4834b4 20627: 4cbe700 20623: d2bd491 v: v3
1 parent 3e25ac7 commit b79c7d9

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,7 +1,7 @@
11
---
22
refs/heads/master: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 4f29814f2a2503f9abb2ccb1e3c286dbf8e8a0d0
4+
refs/heads/snap-stage3: 88877effa8661d20e285aa82a4a5015a4a4c871c
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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;

branches/snap-stage3/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)