about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Holk <eric.holk@gmail.com>2012-07-24 12:11:29 -0700
committerEric Holk <eric.holk@gmail.com>2012-07-25 12:12:25 -0700
commit7ecddb2771922bcd0f117a3a3f681da9bcb8b70c (patch)
treeb801d3c113a7b783fcbef7e9a508cc31bf47e7ea
parentf5be06fa1fed6d9f9467bc644e78292bf94b30f4 (diff)
downloadrust-7ecddb2771922bcd0f117a3a3f681da9bcb8b70c.tar.gz
rust-7ecddb2771922bcd0f117a3a3f681da9bcb8b70c.zip
More purity to make it easier to borrow strings in format strings.
-rw-r--r--src/cargo/cargo.rs2
-rw-r--r--src/libcore/extfmt.rs8
-rw-r--r--src/libcore/str.rs8
3 files changed, 9 insertions, 9 deletions
diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs
index 443d4dda020..87ec11c876e 100644
--- a/src/cargo/cargo.rs
+++ b/src/cargo/cargo.rs
@@ -1616,7 +1616,7 @@ fn cmd_sources(c: cargo) {
     if vec::len(c.opts.free) < 3u {
         for c.sources.each_value |v| {
             info(#fmt("%s (%s) via %s",
-                      copy v.name, copy v.url, copy v.method));
+                      v.name, v.url, v.method));
         }
         ret;
     }
diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs
index eabaffc8995..ec5e9602e19 100644
--- a/src/libcore/extfmt.rs
+++ b/src/libcore/extfmt.rs
@@ -312,7 +312,7 @@ mod rt {
         let mut s = str::from_char(c);
         ret pad(cv, s, pad_nozero);
     }
-    fn conv_str(cv: conv, s: &str) -> ~str {
+    pure fn conv_str(cv: conv, s: &str) -> ~str {
         // For strings, precision is the maximum characters
         // displayed
         let mut unpadded = alt cv.precision {
@@ -323,7 +323,7 @@ mod rt {
             } else { s.to_unique() }
           }
         };
-        ret pad(cv, unpadded, pad_nozero);
+        ret unchecked { pad(cv, unpadded, pad_nozero) };
     }
     fn conv_float(cv: conv, f: float) -> ~str {
         let (to_str, digits) = alt cv.precision {
@@ -398,7 +398,7 @@ mod rt {
           pad_float {   {might_zero_pad:true,  signed:true } }
           pad_unsigned { {might_zero_pad:true,  signed:false} }
         };
-        fn have_precision(cv: conv) -> bool {
+        pure fn have_precision(cv: conv) -> bool {
             ret alt cv.precision { count_implied { false } _ { true } };
         }
         let zero_padding = {
@@ -428,7 +428,7 @@ mod rt {
         }
         ret padstr + s;
     }
-    fn have_flag(flags: u32, f: u32) -> bool {
+    pure fn have_flag(flags: u32, f: u32) -> bool {
         flags & f != 0
     }
 }
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index e915bafafd3..9b142adf165 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -1934,7 +1934,7 @@ trait str_slice {
     fn is_whitespace() -> bool;
     fn is_alphanumeric() -> bool;
     pure fn len() -> uint;
-    fn slice(begin: uint, end: uint) -> ~str;
+    pure fn slice(begin: uint, end: uint) -> ~str;
     fn split(sepfn: fn(char) -> bool) -> ~[~str];
     fn split_char(sep: char) -> ~[~str];
     fn split_str(sep: &a/str) -> ~[~str];
@@ -1944,7 +1944,7 @@ trait str_slice {
     fn to_upper() -> ~str;
     fn escape_default() -> ~str;
     fn escape_unicode() -> ~str;
-    fn to_unique() -> ~str;
+    pure fn to_unique() -> ~str;
 }
 
 /// Extension methods for strings
@@ -2013,7 +2013,7 @@ impl extensions/& of str_slice for &str {
      * beyond the last character of the string
      */
     #[inline]
-    fn slice(begin: uint, end: uint) -> ~str { slice(self, begin, end) }
+    pure fn slice(begin: uint, end: uint) -> ~str { slice(self, begin, end) }
     /// Splits a string into substrings using a character function
     #[inline]
     fn split(sepfn: fn(char) -> bool) -> ~[~str] { split(self, sepfn) }
@@ -2053,7 +2053,7 @@ impl extensions/& of str_slice for &str {
     fn escape_unicode() -> ~str { escape_unicode(self) }
 
     #[inline]
-    fn to_unique() -> ~str { self.slice(0, self.len()) }
+    pure fn to_unique() -> ~str { self.slice(0, self.len()) }
 }
 
 #[cfg(test)]