about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-03-13 14:39:28 -0700
committerBrian Anderson <banderson@mozilla.com>2012-03-13 15:14:17 -0700
commitb968c8e6cd362567bf0047a96d261691dfca43e8 (patch)
tree9cec3e42976bef8815df2a5710083d2bb518b651 /src/libcore
parenta38ccf12547b1bdb37dce3c7edca5b95a898326a (diff)
downloadrust-b968c8e6cd362567bf0047a96d261691dfca43e8.tar.gz
rust-b968c8e6cd362567bf0047a96d261691dfca43e8.zip
Name types after their modules instead of 't'
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/comm.rs2
-rw-r--r--src/libcore/core.rs4
-rw-r--r--src/libcore/either.rs39
-rw-r--r--src/libcore/f32.rs2
-rw-r--r--src/libcore/f64.rs2
-rw-r--r--src/libcore/float.rs2
-rw-r--r--src/libcore/future.rs2
-rw-r--r--src/libcore/io.rs12
-rw-r--r--src/libcore/option.rs20
-rw-r--r--src/libcore/os.rs1
-rw-r--r--src/libcore/result.rs24
-rw-r--r--src/libcore/task.rs2
12 files changed, 54 insertions, 58 deletions
diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs
index e4f0663c443..1572972ffdf 100644
--- a/src/libcore/comm.rs
+++ b/src/libcore/comm.rs
@@ -167,7 +167,7 @@ fn recv_<T: send>(p: *rust_port) -> T {
 #[doc = "Receive on one of two ports"]
 fn select2<A: send, B: send>(
     p_a: port<A>, p_b: port<B>
-) -> either::t<A, B> unsafe {
+) -> either<A, B> unsafe {
 
     fn select(dptr: **rust_port, ports: **rust_port,
               n_ports: libc::size_t, yield: *libc::uintptr_t) {
diff --git a/src/libcore/core.rs b/src/libcore/core.rs
index f83065ff501..5dfb2522f08 100644
--- a/src/libcore/core.rs
+++ b/src/libcore/core.rs
@@ -3,7 +3,9 @@
 // Export various ubiquitous types, constructors, methods.
 
 import option::{some, none};
-import option = option::t;
+import option = option::option;
+import either = either::either;
+import result = result::result;
 import path = path::path;
 import vec::vec_len;
 export path, option, some, none, vec_len, unreachable;
diff --git a/src/libcore/either.rs b/src/libcore/either.rs
index 175c93a3409..a77f19af4e1 100644
--- a/src/libcore/either.rs
+++ b/src/libcore/either.rs
@@ -1,13 +1,13 @@
 #[doc = "A type that represents one of two alternatives"];
 
 #[doc = "The either type"]
-enum t<T, U> {
+enum either<T, U> {
     left(T),
     right(U)
 }
 
 fn either<T, U, V>(f_left: fn(T) -> V,
-                   f_right: fn(U) -> V, value: t<T, U>) -> V {
+                   f_right: fn(U) -> V, value: either<T, U>) -> V {
     #[doc = "
     Applies a function based on the given either value
 
@@ -19,27 +19,27 @@ fn either<T, U, V>(f_left: fn(T) -> V,
     alt value { left(l) { f_left(l) } right(r) { f_right(r) } }
 }
 
-fn lefts<T: copy, U>(eithers: [t<T, U>]) -> [T] {
+fn lefts<T: copy, U>(eithers: [either<T, U>]) -> [T] {
     #[doc = "Extracts from a vector of either all the left values"];
 
     let mut result: [T] = [];
-    for elt: t<T, U> in eithers {
+    for elt: either<T, U> in eithers {
         alt elt { left(l) { result += [l]; } _ {/* fallthrough */ } }
     }
     ret result;
 }
 
-fn rights<T, U: copy>(eithers: [t<T, U>]) -> [U] {
+fn rights<T, U: copy>(eithers: [either<T, U>]) -> [U] {
     #[doc = "Extracts from a vector of either all the right values"];
 
     let mut result: [U] = [];
-    for elt: t<T, U> in eithers {
+    for elt: either<T, U> in eithers {
         alt elt { right(r) { result += [r]; } _ {/* fallthrough */ } }
     }
     ret result;
 }
 
-fn partition<T: copy, U: copy>(eithers: [t<T, U>])
+fn partition<T: copy, U: copy>(eithers: [either<T, U>])
     -> {lefts: [T], rights: [U]} {
     #[doc = "
     Extracts from a vector of either all the left values and right values
@@ -50,13 +50,13 @@ fn partition<T: copy, U: copy>(eithers: [t<T, U>])
 
     let mut lefts: [T] = [];
     let mut rights: [U] = [];
-    for elt: t<T, U> in eithers {
+    for elt: either<T, U> in eithers {
         alt elt { left(l) { lefts += [l]; } right(r) { rights += [r]; } }
     }
     ret {lefts: lefts, rights: rights};
 }
 
-pure fn flip<T: copy, U: copy>(eith: t<T, U>) -> t<U, T> {
+pure fn flip<T: copy, U: copy>(eith: either<T, U>) -> either<U, T> {
     #[doc = "Flips between left and right of a given either"];
 
     alt eith {
@@ -65,7 +65,8 @@ pure fn flip<T: copy, U: copy>(eith: t<T, U>) -> t<U, T> {
     }
 }
 
-pure fn to_result<T: copy, U: copy>(eith: t<T, U>) -> result::t<U, T> {
+pure fn to_result<T: copy, U: copy>(
+    eith: either<T, U>) -> result<U, T> {
     #[doc = "
     Converts either::t to a result::t
 
@@ -79,13 +80,13 @@ pure fn to_result<T: copy, U: copy>(eith: t<T, U>) -> result::t<U, T> {
     }
 }
 
-pure fn is_left<T, U>(eith: t<T, U>) -> bool {
+pure fn is_left<T, U>(eith: either<T, U>) -> bool {
     #[doc = "Checks whether the given value is a left"];
 
     alt eith { left(_) { true } _ { false } }
 }
 
-pure fn is_right<T, U>(eith: t<T, U>) -> bool {
+pure fn is_right<T, U>(eith: either<T, U>) -> bool {
     #[doc = "Checks whether the given value is a right"];
 
     alt eith { right(_) { true } _ { false } }
@@ -116,14 +117,14 @@ fn test_lefts() {
 
 #[test]
 fn test_lefts_none() {
-    let input: [t<int, int>] = [right(10), right(10)];
+    let input: [either<int, int>] = [right(10), right(10)];
     let result = lefts(input);
     assert (vec::len(result) == 0u);
 }
 
 #[test]
 fn test_lefts_empty() {
-    let input: [t<int, int>] = [];
+    let input: [either<int, int>] = [];
     let result = lefts(input);
     assert (vec::len(result) == 0u);
 }
@@ -137,14 +138,14 @@ fn test_rights() {
 
 #[test]
 fn test_rights_none() {
-    let input: [t<int, int>] = [left(10), left(10)];
+    let input: [either<int, int>] = [left(10), left(10)];
     let result = rights(input);
     assert (vec::len(result) == 0u);
 }
 
 #[test]
 fn test_rights_empty() {
-    let input: [t<int, int>] = [];
+    let input: [either<int, int>] = [];
     let result = rights(input);
     assert (vec::len(result) == 0u);
 }
@@ -162,7 +163,7 @@ fn test_partition() {
 
 #[test]
 fn test_partition_no_lefts() {
-    let input: [t<int, int>] = [right(10), right(11)];
+    let input: [either<int, int>] = [right(10), right(11)];
     let result = partition(input);
     assert (vec::len(result.lefts) == 0u);
     assert (vec::len(result.rights) == 2u);
@@ -170,7 +171,7 @@ fn test_partition_no_lefts() {
 
 #[test]
 fn test_partition_no_rights() {
-    let input: [t<int, int>] = [left(10), left(11)];
+    let input: [either<int, int>] = [left(10), left(11)];
     let result = partition(input);
     assert (vec::len(result.lefts) == 2u);
     assert (vec::len(result.rights) == 0u);
@@ -178,7 +179,7 @@ fn test_partition_no_rights() {
 
 #[test]
 fn test_partition_empty() {
-    let input: [t<int, int>] = [];
+    let input: [either<int, int>] = [];
     let result = partition(input);
     assert (vec::len(result.lefts) == 0u);
     assert (vec::len(result.rights) == 0u);
diff --git a/src/libcore/f32.rs b/src/libcore/f32.rs
index 3e3a172ba81..5b9d090db4f 100644
--- a/src/libcore/f32.rs
+++ b/src/libcore/f32.rs
@@ -20,8 +20,6 @@ export lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix;
 export modf, pow, round, sin, sinh, sqrt, tan, tanh, tgamma, trunc;
 export signbit;
 
-type t = f32;
-
 // These are not defined inside consts:: for consistency with
 // the integer types
 
diff --git a/src/libcore/f64.rs b/src/libcore/f64.rs
index 214fcc80188..7cc2846a421 100644
--- a/src/libcore/f64.rs
+++ b/src/libcore/f64.rs
@@ -21,8 +21,6 @@ export modf, pow, round, sin, sinh, sqrt, tan, tanh, tgamma, trunc;
 export signbit;
 export epsilon;
 
-type t = f64;
-
 // These are not defined inside consts:: for consistency with
 // the integer types
 
diff --git a/src/libcore/float.rs b/src/libcore/float.rs
index aec7fd8b0ed..e9aa803e137 100644
--- a/src/libcore/float.rs
+++ b/src/libcore/float.rs
@@ -26,8 +26,6 @@ export j0, j1, jn, y0, y1, yn;
 import m_float = f64;
 import f64::*;
 
-type t = float;
-
 /**
  * Section: String Conversions
  */
diff --git a/src/libcore/future.rs b/src/libcore/future.rs
index faf5cca0e6c..7d2ce8ef44d 100644
--- a/src/libcore/future.rs
+++ b/src/libcore/future.rs
@@ -20,8 +20,6 @@ export get;
 export with;
 export spawn;
 
-import either = either::t;
-
 #[doc = "The future type"]
 enum future<A> = {
     mutable v: either<@A, fn@() -> A>
diff --git a/src/libcore/io.rs b/src/libcore/io.rs
index 23974b789c3..e28876f2134 100644
--- a/src/libcore/io.rs
+++ b/src/libcore/io.rs
@@ -218,7 +218,7 @@ fn FILE_reader(f: *libc::FILE, cleanup: bool) -> reader {
 
 fn stdin() -> reader { rustrt::rust_get_stdin() as reader }
 
-fn file_reader(path: str) -> result::t<reader, str> {
+fn file_reader(path: str) -> result<reader, str> {
     let f = os::as_c_charp(path, {|pathbuf|
         os::as_c_charp("r", {|modebuf|
             libc::fopen(pathbuf, modebuf)
@@ -374,7 +374,7 @@ fn fd_writer(fd: fd_t, cleanup: bool) -> writer {
 
 
 fn mk_file_writer(path: str, flags: [fileflag])
-    -> result::t<writer, str> {
+    -> result<writer, str> {
 
     #[cfg(target_os = "win32")]
     fn wb() -> c_int { (O_WRONLY | O_BINARY) as c_int }
@@ -487,13 +487,13 @@ impl writer_util for writer {
     fn write_u8(n: u8) { self.write([n]) }
 }
 
-fn file_writer(path: str, flags: [fileflag]) -> result::t<writer, str> {
+fn file_writer(path: str, flags: [fileflag]) -> result<writer, str> {
     result::chain(mk_file_writer(path, flags), { |w| result::ok(w)})
 }
 
 
 // FIXME: fileflags
-fn buffered_file_writer(path: str) -> result::t<writer, str> {
+fn buffered_file_writer(path: str) -> result<writer, str> {
     let f = os::as_c_charp(path) {|pathbuf|
         os::as_c_charp("w") {|modebuf|
             libc::fopen(pathbuf, modebuf)
@@ -581,7 +581,7 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) ->
     ret bpos as uint;
 }
 
-fn read_whole_file_str(file: str) -> result::t<str, str> {
+fn read_whole_file_str(file: str) -> result<str, str> {
     result::chain(read_whole_file(file), { |bytes|
         result::ok(str::from_bytes(bytes))
     })
@@ -589,7 +589,7 @@ fn read_whole_file_str(file: str) -> result::t<str, str> {
 
 // FIXME implement this in a low-level way. Going through the abstractions is
 // pointless.
-fn read_whole_file(file: str) -> result::t<[u8], str> {
+fn read_whole_file(file: str) -> result<[u8], str> {
     result::chain(file_reader(file), { |rdr|
         result::ok(rdr.read_whole_stream())
     })
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 47e407e4952..02957cc9f3b 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -8,12 +8,12 @@ languages you might use a nullable type, in Rust you would use an option type.
 "];
 
 #[doc = "The option type"]
-enum t<T> {
+enum option<T> {
     none,
     some(T),
 }
 
-pure fn get<T: copy>(opt: t<T>) -> T {
+pure fn get<T: copy>(opt: option<T>) -> T {
     #[doc = "
     Gets the value out of an option
 
@@ -25,13 +25,13 @@ pure fn get<T: copy>(opt: t<T>) -> T {
     alt opt { some(x) { ret x; } none { fail "option none"; } }
 }
 
-fn map<T, U: copy>(opt: t<T>, f: fn(T) -> U) -> t<U> {
+fn map<T, U: copy>(opt: option<T>, f: fn(T) -> U) -> option<U> {
     #[doc = "Maps a `some` value from one type to another"];
 
     alt opt { some(x) { some(f(x)) } none { none } }
 }
 
-fn chain<T, U>(opt: t<T>, f: fn(T) -> t<U>) -> t<U> {
+fn chain<T, U>(opt: option<T>, f: fn(T) -> option<U>) -> option<U> {
     #[doc = "
     Update an optional value by optionally running its content through a
     function that returns an option.
@@ -40,37 +40,37 @@ fn chain<T, U>(opt: t<T>, f: fn(T) -> t<U>) -> t<U> {
     alt opt { some(x) { f(x) } none { none } }
 }
 
-pure fn is_none<T>(opt: t<T>) -> bool {
+pure fn is_none<T>(opt: option<T>) -> bool {
     #[doc = "Returns true if the option equals `none`"];
 
     alt opt { none { true } some(_) { false } }
 }
 
-pure fn is_some<T>(opt: t<T>) -> bool {
+pure fn is_some<T>(opt: option<T>) -> bool {
     #[doc = "Returns true if the option contains some value"];
 
     !is_none(opt)
 }
 
-pure fn from_maybe<T: copy>(def: T, opt: t<T>) -> T {
+pure fn from_maybe<T: copy>(def: T, opt: option<T>) -> T {
     #[doc = "Returns the contained value or a default"];
 
     alt opt { some(x) { x } none { def } }
 }
 
-fn maybe<T, U: copy>(def: U, opt: t<T>, f: fn(T) -> U) -> U {
+fn maybe<T, U: copy>(def: U, opt: option<T>, f: fn(T) -> U) -> U {
     #[doc = "Applies a function to the contained value or returns a default"];
 
     alt opt { none { def } some(t) { f(t) } }
 }
 
-fn may<T>(opt: t<T>, f: fn(T)) {
+fn may<T>(opt: option<T>, f: fn(T)) {
     #[doc = "Performs an operation on the contained value or does nothing"];
 
     alt opt { none { } some(t) { f(t); } }
 }
 
-fn unwrap<T>(-opt: t<T>) -> T unsafe {
+fn unwrap<T>(-opt: option<T>) -> T unsafe {
     #[doc = "
     Moves a value out of an option type and returns it.
 
diff --git a/src/libcore/os.rs b/src/libcore/os.rs
index e13ccc709ff..1b1474d23fd 100644
--- a/src/libcore/os.rs
+++ b/src/libcore/os.rs
@@ -21,7 +21,6 @@ import libc::{c_char, c_void, c_int, c_uint, size_t, ssize_t,
 import libc::{close, fclose};
 
 import option::{some, none};
-import option = option::t;
 
 import getcwd = rustrt::rust_getcwd;
 import consts::*;
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index b3c01f62f9d..a8ba34b2f3a 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -1,7 +1,7 @@
 #[doc = "A type representing either success or failure"];
 
 #[doc = "The result type"]
-enum t<T, U> {
+enum result<T, U> {
     #[doc = "Contains the successful result value"]
     ok(T),
     #[doc = "Contains the error value"]
@@ -15,7 +15,7 @@ Get the value out of a successful result
 
 If the result is an error
 "]
-fn get<T: copy, U>(res: t<T, U>) -> T {
+fn get<T: copy, U>(res: result<T, U>) -> T {
     alt res {
       ok(t) { t }
       err(_) {
@@ -33,7 +33,7 @@ Get the value out of an error result
 
 If the result is not an error
 "]
-fn get_err<T, U: copy>(res: t<T, U>) -> U {
+fn get_err<T, U: copy>(res: result<T, U>) -> U {
     alt res {
       err(u) { u }
       ok(_) {
@@ -43,7 +43,7 @@ fn get_err<T, U: copy>(res: t<T, U>) -> U {
 }
 
 #[doc = "Returns true if the result is `ok`"]
-pure fn success<T, U>(res: t<T, U>) -> bool {
+pure fn success<T, U>(res: result<T, U>) -> bool {
     alt res {
       ok(_) { true }
       err(_) { false }
@@ -51,7 +51,7 @@ pure fn success<T, U>(res: t<T, U>) -> bool {
 }
 
 #[doc = "Returns true if the result is `error`"]
-pure fn failure<T, U>(res: t<T, U>) -> bool {
+pure fn failure<T, U>(res: result<T, U>) -> bool {
     !success(res)
 }
 
@@ -61,7 +61,7 @@ Convert to the `either` type
 `ok` result variants are converted to `either::right` variants, `err`
 result variants are converted to `either::left`.
 "]
-pure fn to_either<T: copy, U: copy>(res: t<U, T>) -> either::t<T, U> {
+pure fn to_either<T: copy, U: copy>(res: result<U, T>) -> either<T, U> {
     alt res {
       ok(res) { either::right(res) }
       err(fail_) { either::left(fail_) }
@@ -81,8 +81,8 @@ Example:
         ok(parse_buf(buf))
     }
 "]
-fn chain<T, U: copy, V: copy>(res: t<T, V>, op: fn(T) -> t<U, V>)
-    -> t<U, V> {
+fn chain<T, U: copy, V: copy>(res: result<T, V>, op: fn(T) -> result<U, V>)
+    -> result<U, V> {
     alt res {
       ok(t) { op(t) }
       err(e) { err(e) }
@@ -91,11 +91,13 @@ fn chain<T, U: copy, V: copy>(res: t<T, V>, op: fn(T) -> t<U, V>)
 
 #[cfg(test)]
 mod tests {
-    fn op1() -> result::t<int, str> { result::ok(666) }
+    fn op1() -> result::result<int, str> { result::ok(666) }
 
-    fn op2(&&i: int) -> result::t<uint, str> { result::ok(i as uint + 1u) }
+    fn op2(&&i: int) -> result::result<uint, str> {
+        result::ok(i as uint + 1u)
+    }
 
-    fn op3() -> result::t<int, str> { result::err("sadface") }
+    fn op3() -> result::result<int, str> { result::err("sadface") }
 
     #[test]
     fn chain_success() {
diff --git a/src/libcore/task.rs b/src/libcore/task.rs
index 806fd951189..c673fbf9b84 100644
--- a/src/libcore/task.rs
+++ b/src/libcore/task.rs
@@ -406,7 +406,7 @@ fn spawn_sched(mode: sched_mode, +f: fn~()) {
     run(builder, f);
 }
 
-fn try<T:send>(+f: fn~() -> T) -> result::t<T,()> {
+fn try<T:send>(+f: fn~() -> T) -> result<T,()> {
     #[doc = "
     Execute a function in another task and return either the return value
     of the function or result::err.