Skip to content

Commit 7ecddb2

Browse files
committed
More purity to make it easier to borrow strings in format strings.
1 parent f5be06f commit 7ecddb2

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/cargo/cargo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ fn cmd_sources(c: cargo) {
16161616
if vec::len(c.opts.free) < 3u {
16171617
for c.sources.each_value |v| {
16181618
info(#fmt("%s (%s) via %s",
1619-
copy v.name, copy v.url, copy v.method));
1619+
v.name, v.url, v.method));
16201620
}
16211621
ret;
16221622
}

src/libcore/extfmt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ 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+
pure 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 {
@@ -323,7 +323,7 @@ mod rt {
323323
} else { s.to_unique() }
324324
}
325325
};
326-
ret pad(cv, unpadded, pad_nozero);
326+
ret unchecked { pad(cv, unpadded, pad_nozero) };
327327
}
328328
fn conv_float(cv: conv, f: float) -> ~str {
329329
let (to_str, digits) = alt cv.precision {
@@ -398,7 +398,7 @@ mod rt {
398398
pad_float { {might_zero_pad:true, signed:true } }
399399
pad_unsigned { {might_zero_pad:true, signed:false} }
400400
};
401-
fn have_precision(cv: conv) -> bool {
401+
pure fn have_precision(cv: conv) -> bool {
402402
ret alt cv.precision { count_implied { false } _ { true } };
403403
}
404404
let zero_padding = {
@@ -428,7 +428,7 @@ mod rt {
428428
}
429429
ret padstr + s;
430430
}
431-
fn have_flag(flags: u32, f: u32) -> bool {
431+
pure fn have_flag(flags: u32, f: u32) -> bool {
432432
flags & f != 0
433433
}
434434
}

src/libcore/str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,7 @@ trait str_slice {
19341934
fn is_whitespace() -> bool;
19351935
fn is_alphanumeric() -> bool;
19361936
pure fn len() -> uint;
1937-
fn slice(begin: uint, end: uint) -> ~str;
1937+
pure fn slice(begin: uint, end: uint) -> ~str;
19381938
fn split(sepfn: fn(char) -> bool) -> ~[~str];
19391939
fn split_char(sep: char) -> ~[~str];
19401940
fn split_str(sep: &a/str) -> ~[~str];
@@ -1944,7 +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;
1947+
pure fn to_unique() -> ~str;
19481948
}
19491949

19501950
/// Extension methods for strings
@@ -2013,7 +2013,7 @@ impl extensions/& of str_slice for &str {
20132013
* beyond the last character of the string
20142014
*/
20152015
#[inline]
2016-
fn slice(begin: uint, end: uint) -> ~str { slice(self, begin, end) }
2016+
pure fn slice(begin: uint, end: uint) -> ~str { slice(self, begin, end) }
20172017
/// Splits a string into substrings using a character function
20182018
#[inline]
20192019
fn split(sepfn: fn(char) -> bool) -> ~[~str] { split(self, sepfn) }
@@ -2053,7 +2053,7 @@ impl extensions/& of str_slice for &str {
20532053
fn escape_unicode() -> ~str { escape_unicode(self) }
20542054

20552055
#[inline]
2056-
fn to_unique() -> ~str { self.slice(0, self.len()) }
2056+
pure fn to_unique() -> ~str { self.slice(0, self.len()) }
20572057
}
20582058

20592059
#[cfg(test)]

0 commit comments

Comments
 (0)