Skip to content

Commit bed457d

Browse files
brsongraydon
authored andcommitted
Change io.fileflag to a tag type. Remove FIXME
1 parent 330c9c6 commit bed457d

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

src/lib/io.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,11 @@ fn new_buf_reader(str path) -> buf_reader {
8585
ret fd_buf_reader(fd, new_buf());
8686
}
8787

88-
/**
89-
* FIXME (issue #150): This should be
90-
*
91-
* type fileflag = tag(append(), create(), truncate());
92-
*
93-
* but then the tag value ctors are not found from crate-importers of std, so
94-
* we manually simulate the enum below.
95-
*/
96-
type fileflag = uint;
97-
fn append() -> uint { ret 0u; }
98-
fn create() -> uint { ret 1u; }
99-
fn truncate() -> uint { ret 2u; }
88+
tag fileflag {
89+
append;
90+
create;
91+
truncate;
92+
}
10093

10194
fn new_buf_writer(str path, vec[fileflag] flags) -> buf_writer {
10295

@@ -129,13 +122,9 @@ fn new_buf_writer(str path, vec[fileflag] flags) -> buf_writer {
129122

130123
for (fileflag f in flags) {
131124
alt (f) {
132-
// FIXME (issue #150): cf comment above defn of fileflag type
133-
//case (append()) { fflags |= os.libc_constants.O_APPEND(); }
134-
//case (create()) { fflags |= os.libc_constants.O_CREAT(); }
135-
//case (truncate()) { fflags |= os.libc_constants.O_TRUNC(); }
136-
case (0u) { fflags |= os.libc_constants.O_APPEND(); }
137-
case (1u) { fflags |= os.libc_constants.O_CREAT(); }
138-
case (2u) { fflags |= os.libc_constants.O_TRUNC(); }
125+
case (append) { fflags |= os.libc_constants.O_APPEND(); }
126+
case (create) { fflags |= os.libc_constants.O_CREAT(); }
127+
case (truncate) { fflags |= os.libc_constants.O_TRUNC(); }
139128
}
140129
}
141130

src/test/run-pass/lib-io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn test_simple(str tmpfilebase) {
1111
log frood;
1212

1313
{
14-
let io.buf_writer out = io.new_buf_writer(tmpfile, vec(io.create()));
14+
let io.buf_writer out = io.new_buf_writer(tmpfile, vec(io.create));
1515
out.write(_str.bytes(frood));
1616
}
1717

0 commit comments

Comments
 (0)