Skip to content

Commit f9547cf

Browse files
committed
---
yaml --- r: 31401 b: refs/heads/dist-snap c: 88877ef h: refs/heads/master i: 31399: 7631c33 v: v3
1 parent 68dd199 commit f9547cf

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
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: 4f29814f2a2503f9abb2ccb1e3c286dbf8e8a0d0
10+
refs/heads/dist-snap: 88877effa8661d20e285aa82a4a5015a4a4c871c
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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