Skip to content

Commit 7b30cc7

Browse files
committed
---
yaml --- r: 11816 b: refs/heads/master c: b968c8e h: refs/heads/master v: v3
1 parent 01a6976 commit 7b30cc7

File tree

30 files changed

+191
-190
lines changed

30 files changed

+191
-190
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: a38ccf12547b1bdb37dce3c7edca5b95a898326a
2+
refs/heads/master: b968c8e6cd362567bf0047a96d261691dfca43e8
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/doc/tutorial.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,11 +1540,11 @@ You can then declare a function to take a `circular_buf<u8>` or return
15401540
an `option<str>`, or even an `option<T>` if the function itself is
15411541
generic.
15421542

1543-
The `option` type given above exists in the core library as
1544-
`option::t`, and is the way Rust programs express the thing that in C
1545-
would be a nullable pointer. The nice part is that you have to
1546-
explicitly unpack an `option` type, so accidental null pointer
1547-
dereferences become impossible.
1543+
The `option` type given above exists in the core library and is the
1544+
way Rust programs express the thing that in C would be a nullable
1545+
pointer. The nice part is that you have to explicitly unpack an
1546+
`option` type, so accidental null pointer dereferences become
1547+
impossible.
15481548

15491549
## Type-inference and generics
15501550

@@ -1562,7 +1562,7 @@ you really want to have such a statement, you'll have to write it like
15621562
this:
15631563

15641564
~~~~
1565-
let n2: option::t<int> = option::none;
1565+
let n2: option<int> = option::none;
15661566
// or
15671567
let n = option::none::<int>;
15681568
~~~~

trunk/src/libcore/comm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn recv_<T: send>(p: *rust_port) -> T {
167167
#[doc = "Receive on one of two ports"]
168168
fn select2<A: send, B: send>(
169169
p_a: port<A>, p_b: port<B>
170-
) -> either::t<A, B> unsafe {
170+
) -> either<A, B> unsafe {
171171

172172
fn select(dptr: **rust_port, ports: **rust_port,
173173
n_ports: libc::size_t, yield: *libc::uintptr_t) {

trunk/src/libcore/core.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
// Export various ubiquitous types, constructors, methods.
44

55
import option::{some, none};
6-
import option = option::t;
6+
import option = option::option;
7+
import either = either::either;
8+
import result = result::result;
79
import path = path::path;
810
import vec::vec_len;
911
export path, option, some, none, vec_len, unreachable;

trunk/src/libcore/either.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#[doc = "A type that represents one of two alternatives"];
22

33
#[doc = "The either type"]
4-
enum t<T, U> {
4+
enum either<T, U> {
55
left(T),
66
right(U)
77
}
88

99
fn either<T, U, V>(f_left: fn(T) -> V,
10-
f_right: fn(U) -> V, value: t<T, U>) -> V {
10+
f_right: fn(U) -> V, value: either<T, U>) -> V {
1111
#[doc = "
1212
Applies a function based on the given either value
1313
@@ -19,27 +19,27 @@ fn either<T, U, V>(f_left: fn(T) -> V,
1919
alt value { left(l) { f_left(l) } right(r) { f_right(r) } }
2020
}
2121

22-
fn lefts<T: copy, U>(eithers: [t<T, U>]) -> [T] {
22+
fn lefts<T: copy, U>(eithers: [either<T, U>]) -> [T] {
2323
#[doc = "Extracts from a vector of either all the left values"];
2424

2525
let mut result: [T] = [];
26-
for elt: t<T, U> in eithers {
26+
for elt: either<T, U> in eithers {
2727
alt elt { left(l) { result += [l]; } _ {/* fallthrough */ } }
2828
}
2929
ret result;
3030
}
3131

32-
fn rights<T, U: copy>(eithers: [t<T, U>]) -> [U] {
32+
fn rights<T, U: copy>(eithers: [either<T, U>]) -> [U] {
3333
#[doc = "Extracts from a vector of either all the right values"];
3434

3535
let mut result: [U] = [];
36-
for elt: t<T, U> in eithers {
36+
for elt: either<T, U> in eithers {
3737
alt elt { right(r) { result += [r]; } _ {/* fallthrough */ } }
3838
}
3939
ret result;
4040
}
4141

42-
fn partition<T: copy, U: copy>(eithers: [t<T, U>])
42+
fn partition<T: copy, U: copy>(eithers: [either<T, U>])
4343
-> {lefts: [T], rights: [U]} {
4444
#[doc = "
4545
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>])
5050

5151
let mut lefts: [T] = [];
5252
let mut rights: [U] = [];
53-
for elt: t<T, U> in eithers {
53+
for elt: either<T, U> in eithers {
5454
alt elt { left(l) { lefts += [l]; } right(r) { rights += [r]; } }
5555
}
5656
ret {lefts: lefts, rights: rights};
5757
}
5858

59-
pure fn flip<T: copy, U: copy>(eith: t<T, U>) -> t<U, T> {
59+
pure fn flip<T: copy, U: copy>(eith: either<T, U>) -> either<U, T> {
6060
#[doc = "Flips between left and right of a given either"];
6161

6262
alt eith {
@@ -65,7 +65,8 @@ pure fn flip<T: copy, U: copy>(eith: t<T, U>) -> t<U, T> {
6565
}
6666
}
6767

68-
pure fn to_result<T: copy, U: copy>(eith: t<T, U>) -> result::t<U, T> {
68+
pure fn to_result<T: copy, U: copy>(
69+
eith: either<T, U>) -> result<U, T> {
6970
#[doc = "
7071
Converts either::t to a result::t
7172
@@ -79,13 +80,13 @@ pure fn to_result<T: copy, U: copy>(eith: t<T, U>) -> result::t<U, T> {
7980
}
8081
}
8182

82-
pure fn is_left<T, U>(eith: t<T, U>) -> bool {
83+
pure fn is_left<T, U>(eith: either<T, U>) -> bool {
8384
#[doc = "Checks whether the given value is a left"];
8485

8586
alt eith { left(_) { true } _ { false } }
8687
}
8788

88-
pure fn is_right<T, U>(eith: t<T, U>) -> bool {
89+
pure fn is_right<T, U>(eith: either<T, U>) -> bool {
8990
#[doc = "Checks whether the given value is a right"];
9091

9192
alt eith { right(_) { true } _ { false } }
@@ -116,14 +117,14 @@ fn test_lefts() {
116117

117118
#[test]
118119
fn test_lefts_none() {
119-
let input: [t<int, int>] = [right(10), right(10)];
120+
let input: [either<int, int>] = [right(10), right(10)];
120121
let result = lefts(input);
121122
assert (vec::len(result) == 0u);
122123
}
123124

124125
#[test]
125126
fn test_lefts_empty() {
126-
let input: [t<int, int>] = [];
127+
let input: [either<int, int>] = [];
127128
let result = lefts(input);
128129
assert (vec::len(result) == 0u);
129130
}
@@ -137,14 +138,14 @@ fn test_rights() {
137138

138139
#[test]
139140
fn test_rights_none() {
140-
let input: [t<int, int>] = [left(10), left(10)];
141+
let input: [either<int, int>] = [left(10), left(10)];
141142
let result = rights(input);
142143
assert (vec::len(result) == 0u);
143144
}
144145

145146
#[test]
146147
fn test_rights_empty() {
147-
let input: [t<int, int>] = [];
148+
let input: [either<int, int>] = [];
148149
let result = rights(input);
149150
assert (vec::len(result) == 0u);
150151
}
@@ -162,23 +163,23 @@ fn test_partition() {
162163

163164
#[test]
164165
fn test_partition_no_lefts() {
165-
let input: [t<int, int>] = [right(10), right(11)];
166+
let input: [either<int, int>] = [right(10), right(11)];
166167
let result = partition(input);
167168
assert (vec::len(result.lefts) == 0u);
168169
assert (vec::len(result.rights) == 2u);
169170
}
170171

171172
#[test]
172173
fn test_partition_no_rights() {
173-
let input: [t<int, int>] = [left(10), left(11)];
174+
let input: [either<int, int>] = [left(10), left(11)];
174175
let result = partition(input);
175176
assert (vec::len(result.lefts) == 2u);
176177
assert (vec::len(result.rights) == 0u);
177178
}
178179

179180
#[test]
180181
fn test_partition_empty() {
181-
let input: [t<int, int>] = [];
182+
let input: [either<int, int>] = [];
182183
let result = partition(input);
183184
assert (vec::len(result.lefts) == 0u);
184185
assert (vec::len(result.rights) == 0u);

trunk/src/libcore/f32.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ export lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix;
2020
export modf, pow, round, sin, sinh, sqrt, tan, tanh, tgamma, trunc;
2121
export signbit;
2222

23-
type t = f32;
24-
2523
// These are not defined inside consts:: for consistency with
2624
// the integer types
2725

trunk/src/libcore/f64.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ export modf, pow, round, sin, sinh, sqrt, tan, tanh, tgamma, trunc;
2121
export signbit;
2222
export epsilon;
2323

24-
type t = f64;
25-
2624
// These are not defined inside consts:: for consistency with
2725
// the integer types
2826

trunk/src/libcore/float.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ export j0, j1, jn, y0, y1, yn;
2626
import m_float = f64;
2727
import f64::*;
2828

29-
type t = float;
30-
3129
/**
3230
* Section: String Conversions
3331
*/

trunk/src/libcore/future.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ export get;
2020
export with;
2121
export spawn;
2222

23-
import either = either::t;
24-
2523
#[doc = "The future type"]
2624
enum future<A> = {
2725
mutable v: either<@A, fn@() -> A>

trunk/src/libcore/io.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ fn FILE_reader(f: *libc::FILE, cleanup: bool) -> reader {
218218

219219
fn stdin() -> reader { rustrt::rust_get_stdin() as reader }
220220

221-
fn file_reader(path: str) -> result::t<reader, str> {
221+
fn file_reader(path: str) -> result<reader, str> {
222222
let f = os::as_c_charp(path, {|pathbuf|
223223
os::as_c_charp("r", {|modebuf|
224224
libc::fopen(pathbuf, modebuf)
@@ -374,7 +374,7 @@ fn fd_writer(fd: fd_t, cleanup: bool) -> writer {
374374

375375

376376
fn mk_file_writer(path: str, flags: [fileflag])
377-
-> result::t<writer, str> {
377+
-> result<writer, str> {
378378

379379
#[cfg(target_os = "win32")]
380380
fn wb() -> c_int { (O_WRONLY | O_BINARY) as c_int }
@@ -487,13 +487,13 @@ impl writer_util for writer {
487487
fn write_u8(n: u8) { self.write([n]) }
488488
}
489489

490-
fn file_writer(path: str, flags: [fileflag]) -> result::t<writer, str> {
490+
fn file_writer(path: str, flags: [fileflag]) -> result<writer, str> {
491491
result::chain(mk_file_writer(path, flags), { |w| result::ok(w)})
492492
}
493493

494494

495495
// FIXME: fileflags
496-
fn buffered_file_writer(path: str) -> result::t<writer, str> {
496+
fn buffered_file_writer(path: str) -> result<writer, str> {
497497
let f = os::as_c_charp(path) {|pathbuf|
498498
os::as_c_charp("w") {|modebuf|
499499
libc::fopen(pathbuf, modebuf)
@@ -581,15 +581,15 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) ->
581581
ret bpos as uint;
582582
}
583583

584-
fn read_whole_file_str(file: str) -> result::t<str, str> {
584+
fn read_whole_file_str(file: str) -> result<str, str> {
585585
result::chain(read_whole_file(file), { |bytes|
586586
result::ok(str::from_bytes(bytes))
587587
})
588588
}
589589

590590
// FIXME implement this in a low-level way. Going through the abstractions is
591591
// pointless.
592-
fn read_whole_file(file: str) -> result::t<[u8], str> {
592+
fn read_whole_file(file: str) -> result<[u8], str> {
593593
result::chain(file_reader(file), { |rdr|
594594
result::ok(rdr.read_whole_stream())
595595
})

trunk/src/libcore/option.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ languages you might use a nullable type, in Rust you would use an option type.
88
"];
99

1010
#[doc = "The option type"]
11-
enum t<T> {
11+
enum option<T> {
1212
none,
1313
some(T),
1414
}
1515

16-
pure fn get<T: copy>(opt: t<T>) -> T {
16+
pure fn get<T: copy>(opt: option<T>) -> T {
1717
#[doc = "
1818
Gets the value out of an option
1919
@@ -25,13 +25,13 @@ pure fn get<T: copy>(opt: t<T>) -> T {
2525
alt opt { some(x) { ret x; } none { fail "option none"; } }
2626
}
2727

28-
fn map<T, U: copy>(opt: t<T>, f: fn(T) -> U) -> t<U> {
28+
fn map<T, U: copy>(opt: option<T>, f: fn(T) -> U) -> option<U> {
2929
#[doc = "Maps a `some` value from one type to another"];
3030

3131
alt opt { some(x) { some(f(x)) } none { none } }
3232
}
3333

34-
fn chain<T, U>(opt: t<T>, f: fn(T) -> t<U>) -> t<U> {
34+
fn chain<T, U>(opt: option<T>, f: fn(T) -> option<U>) -> option<U> {
3535
#[doc = "
3636
Update an optional value by optionally running its content through a
3737
function that returns an option.
@@ -40,37 +40,37 @@ fn chain<T, U>(opt: t<T>, f: fn(T) -> t<U>) -> t<U> {
4040
alt opt { some(x) { f(x) } none { none } }
4141
}
4242

43-
pure fn is_none<T>(opt: t<T>) -> bool {
43+
pure fn is_none<T>(opt: option<T>) -> bool {
4444
#[doc = "Returns true if the option equals `none`"];
4545

4646
alt opt { none { true } some(_) { false } }
4747
}
4848

49-
pure fn is_some<T>(opt: t<T>) -> bool {
49+
pure fn is_some<T>(opt: option<T>) -> bool {
5050
#[doc = "Returns true if the option contains some value"];
5151

5252
!is_none(opt)
5353
}
5454

55-
pure fn from_maybe<T: copy>(def: T, opt: t<T>) -> T {
55+
pure fn from_maybe<T: copy>(def: T, opt: option<T>) -> T {
5656
#[doc = "Returns the contained value or a default"];
5757

5858
alt opt { some(x) { x } none { def } }
5959
}
6060

61-
fn maybe<T, U: copy>(def: U, opt: t<T>, f: fn(T) -> U) -> U {
61+
fn maybe<T, U: copy>(def: U, opt: option<T>, f: fn(T) -> U) -> U {
6262
#[doc = "Applies a function to the contained value or returns a default"];
6363

6464
alt opt { none { def } some(t) { f(t) } }
6565
}
6666

67-
fn may<T>(opt: t<T>, f: fn(T)) {
67+
fn may<T>(opt: option<T>, f: fn(T)) {
6868
#[doc = "Performs an operation on the contained value or does nothing"];
6969

7070
alt opt { none { } some(t) { f(t); } }
7171
}
7272

73-
fn unwrap<T>(-opt: t<T>) -> T unsafe {
73+
fn unwrap<T>(-opt: option<T>) -> T unsafe {
7474
#[doc = "
7575
Moves a value out of an option type and returns it.
7676

trunk/src/libcore/os.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import libc::{c_char, c_void, c_int, c_uint, size_t, ssize_t,
2121
import libc::{close, fclose};
2222

2323
import option::{some, none};
24-
import option = option::t;
2524

2625
import getcwd = rustrt::rust_getcwd;
2726
import consts::*;

0 commit comments

Comments
 (0)