Allow logging slices
This commit is contained in:
parent
4f29814f2a
commit
88877effa8
@ -312,15 +312,15 @@ mod rt {
|
||||
let mut s = str::from_char(c);
|
||||
ret pad(cv, s, pad_nozero);
|
||||
}
|
||||
fn conv_str(cv: conv, s: ~str) -> ~str {
|
||||
fn conv_str(cv: conv, s: &str) -> ~str {
|
||||
// For strings, precision is the maximum characters
|
||||
// displayed
|
||||
let mut unpadded = alt cv.precision {
|
||||
count_implied { s }
|
||||
count_implied { s.to_unique() }
|
||||
count_is(max) {
|
||||
if max as uint < str::char_len(s) {
|
||||
str::substr(s, 0u, max as uint)
|
||||
} else { s }
|
||||
} else { s.to_unique() }
|
||||
}
|
||||
};
|
||||
ret pad(cv, unpadded, pad_nozero);
|
||||
@ -433,6 +433,14 @@ mod rt {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
#[test]
|
||||
fn fmt_slice() {
|
||||
let s = "abc";
|
||||
let _s = #fmt("%s", s);
|
||||
}
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust;
|
||||
|
@ -1944,6 +1944,7 @@ trait str_slice {
|
||||
fn to_upper() -> ~str;
|
||||
fn escape_default() -> ~str;
|
||||
fn escape_unicode() -> ~str;
|
||||
fn to_unique() -> ~str;
|
||||
}
|
||||
|
||||
/// Extension methods for strings
|
||||
@ -2050,6 +2051,9 @@ impl extensions/& of str_slice for &str {
|
||||
/// Escape each char in `s` with char::escape_unicode.
|
||||
#[inline]
|
||||
fn escape_unicode() -> ~str { escape_unicode(self) }
|
||||
|
||||
#[inline]
|
||||
fn to_unique() -> ~str { self.slice(0, self.len()) }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user