about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2012-09-14 09:55:33 -0700
committerErick Tryzelaar <erick.tryzelaar@gmail.com>2012-09-15 13:38:41 -0700
commitb73f801cc11ccddfe973112a040807cd164893f8 (patch)
tree1c31060d9d5ee0fc9ecdfa3e801226d3aac52211 /src/libcore
parent651e63cc5c2b90204e8cd9d263da567fe2a66fbf (diff)
int/uint parse_buf => parse_bytes (#3444)
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/int-template.rs48
-rw-r--r--src/libcore/result.rs4
-rw-r--r--src/libcore/uint-template.rs26
3 files changed, 39 insertions, 39 deletions
diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs
index a7c3c4e0d0a..664f2940ec7 100644
--- a/src/libcore/int-template.rs
+++ b/src/libcore/int-template.rs
@@ -16,7 +16,7 @@ export is_nonpositive, is_nonnegative;
 export range;
 export compl;
 export abs;
-export parse_buf, from_str, to_str, to_str_bytes, str;
+export parse_bytes, from_str, to_str, to_str_bytes, str;
 export num, ord, eq, times, timesi;
 export bits, bytes;
 
@@ -137,7 +137,7 @@ impl T: iter::TimesIx {
  * * buf - A byte buffer
  * * radix - The base of the number
  */
-fn parse_buf(buf: &[u8], radix: uint) -> Option<T> {
+fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
     if vec::len(buf) == 0u { return None; }
     let mut i = vec::len(buf) - 1u;
     let mut start = 0u;
@@ -160,7 +160,7 @@ fn parse_buf(buf: &[u8], radix: uint) -> Option<T> {
 }
 
 /// Parse a string to an int
-fn from_str(s: &str) -> Option<T> { parse_buf(str::to_bytes(s), 10u) }
+fn from_str(s: &str) -> Option<T> { parse_bytes(str::to_bytes(s), 10u) }
 
 impl T : FromStr {
     static fn from_str(s: &str) -> Option<T> { from_str(s) }
@@ -209,28 +209,28 @@ fn test_from_str() {
 // FIXME: Has alignment issues on windows and 32-bit linux (#2609)
 #[test]
 #[ignore]
-fn test_parse_buf() {
+fn test_parse_bytes() {
     use str::to_bytes;
-    assert parse_buf(to_bytes(~"123"), 10u) == Some(123 as T);
-    assert parse_buf(to_bytes(~"1001"), 2u) == Some(9 as T);
-    assert parse_buf(to_bytes(~"123"), 8u) == Some(83 as T);
-    assert parse_buf(to_bytes(~"123"), 16u) == Some(291 as T);
-    assert parse_buf(to_bytes(~"ffff"), 16u) == Some(65535 as T);
-    assert parse_buf(to_bytes(~"FFFF"), 16u) == Some(65535 as T);
-    assert parse_buf(to_bytes(~"z"), 36u) == Some(35 as T);
-    assert parse_buf(to_bytes(~"Z"), 36u) == Some(35 as T);
-
-    assert parse_buf(to_bytes(~"-123"), 10u) == Some(-123 as T);
-    assert parse_buf(to_bytes(~"-1001"), 2u) == Some(-9 as T);
-    assert parse_buf(to_bytes(~"-123"), 8u) == Some(-83 as T);
-    assert parse_buf(to_bytes(~"-123"), 16u) == Some(-291 as T);
-    assert parse_buf(to_bytes(~"-ffff"), 16u) == Some(-65535 as T);
-    assert parse_buf(to_bytes(~"-FFFF"), 16u) == Some(-65535 as T);
-    assert parse_buf(to_bytes(~"-z"), 36u) == Some(-35 as T);
-    assert parse_buf(to_bytes(~"-Z"), 36u) == Some(-35 as T);
-
-    assert parse_buf(to_bytes(~"Z"), 35u).is_none();
-    assert parse_buf(to_bytes(~"-9"), 2u).is_none();
+    assert parse_bytes(to_bytes(~"123"), 10u) == Some(123 as T);
+    assert parse_bytes(to_bytes(~"1001"), 2u) == Some(9 as T);
+    assert parse_bytes(to_bytes(~"123"), 8u) == Some(83 as T);
+    assert parse_bytes(to_bytes(~"123"), 16u) == Some(291 as T);
+    assert parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535 as T);
+    assert parse_bytes(to_bytes(~"FFFF"), 16u) == Some(65535 as T);
+    assert parse_bytes(to_bytes(~"z"), 36u) == Some(35 as T);
+    assert parse_bytes(to_bytes(~"Z"), 36u) == Some(35 as T);
+
+    assert parse_bytes(to_bytes(~"-123"), 10u) == Some(-123 as T);
+    assert parse_bytes(to_bytes(~"-1001"), 2u) == Some(-9 as T);
+    assert parse_bytes(to_bytes(~"-123"), 8u) == Some(-83 as T);
+    assert parse_bytes(to_bytes(~"-123"), 16u) == Some(-291 as T);
+    assert parse_bytes(to_bytes(~"-ffff"), 16u) == Some(-65535 as T);
+    assert parse_bytes(to_bytes(~"-FFFF"), 16u) == Some(-65535 as T);
+    assert parse_bytes(to_bytes(~"-z"), 36u) == Some(-35 as T);
+    assert parse_bytes(to_bytes(~"-Z"), 36u) == Some(-35 as T);
+
+    assert parse_bytes(to_bytes(~"Z"), 35u).is_none();
+    assert parse_bytes(to_bytes(~"-9"), 2u).is_none();
 }
 
 #[test]
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 7330d3520f6..cdd8ab11658 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -94,7 +94,7 @@ pure fn to_either<T: Copy, U: Copy>(res: Result<U, T>) -> Either<T, U> {
  * Example:
  *
  *     let res = chain(read_file(file)) { |buf|
- *         ok(parse_buf(buf))
+ *         ok(parse_bytes(buf))
  *     }
  */
 fn chain<T, U: Copy, V: Copy>(res: Result<T, V>, op: fn(T) -> Result<U, V>)
@@ -170,7 +170,7 @@ fn iter_err<T, E>(res: Result<T, E>, f: fn(E)) {
  * Example:
  *
  *     let res = map(read_file(file)) { |buf|
- *         parse_buf(buf)
+ *         parse_bytes(buf)
  *     }
  */
 fn map<T, E: Copy, U: Copy>(res: Result<T, E>, op: fn(T) -> U)
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs
index 80617fba844..02faf9255ef 100644
--- a/src/libcore/uint-template.rs
+++ b/src/libcore/uint-template.rs
@@ -15,7 +15,7 @@ export is_nonpositive, is_nonnegative;
 export range;
 export compl;
 export to_str, to_str_bytes;
-export from_str, from_str_radix, str, parse_buf;
+export from_str, from_str_radix, str, parse_bytes;
 export num, ord, eq, times, timesi;
 export bits, bytes;
 
@@ -126,7 +126,7 @@ impl T: iter::TimesIx {
  *
  * `buf` must not be empty
  */
-fn parse_buf(buf: &[const u8], radix: uint) -> Option<T> {
+fn parse_bytes(buf: &[const u8], radix: uint) -> Option<T> {
     if vec::len(buf) == 0u { return None; }
     let mut i = vec::len(buf) - 1u;
     let mut power = 1u as T;
@@ -143,7 +143,7 @@ fn parse_buf(buf: &[const u8], radix: uint) -> Option<T> {
 }
 
 /// Parse a string to an int
-fn from_str(s: &str) -> Option<T> { parse_buf(str::to_bytes(s), 10u) }
+fn from_str(s: &str) -> Option<T> { parse_bytes(str::to_bytes(s), 10u) }
 
 impl T : FromStr {
     static fn from_str(s: &str) -> Option<T> { from_str(s) }
@@ -275,17 +275,17 @@ fn test_from_str() {
 
 #[test]
 #[ignore]
-fn test_parse_buf() {
+fn test_parse_bytes() {
     use str::to_bytes;
-    assert parse_buf(to_bytes(~"123"), 10u) == Some(123u as T);
-    assert parse_buf(to_bytes(~"1001"), 2u) == Some(9u as T);
-    assert parse_buf(to_bytes(~"123"), 8u) == Some(83u as T);
-    assert parse_buf(to_bytes(~"123"), 16u) == Some(291u as T);
-    assert parse_buf(to_bytes(~"ffff"), 16u) == Some(65535u as T);
-    assert parse_buf(to_bytes(~"z"), 36u) == Some(35u as T);
-
-    assert parse_buf(to_bytes(~"Z"), 10u).is_none();
-    assert parse_buf(to_bytes(~"_"), 2u).is_none();
+    assert parse_bytes(to_bytes(~"123"), 10u) == Some(123u as T);
+    assert parse_bytes(to_bytes(~"1001"), 2u) == Some(9u as T);
+    assert parse_bytes(to_bytes(~"123"), 8u) == Some(83u as T);
+    assert parse_bytes(to_bytes(~"123"), 16u) == Some(291u as T);
+    assert parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535u as T);
+    assert parse_bytes(to_bytes(~"z"), 36u) == Some(35u as T);
+
+    assert parse_bytes(to_bytes(~"Z"), 10u).is_none();
+    assert parse_bytes(to_bytes(~"_"), 2u).is_none();
 }
 
 #[test]