mirror of
https://github.com/rust-lang/rust
synced 2024-10-06 08:40:35 +00:00
stdlib: Provide a function to extract the underlying buf_writer from a writer
This commit is contained in:
parent
23e23bd762
commit
c1bc0101ca
|
@ -223,6 +223,7 @@ fn file_buf_writer(str path, vec[fileflag] flags) -> buf_writer {
|
|||
|
||||
type writer =
|
||||
state obj {
|
||||
fn get_buf_writer() -> buf_writer;
|
||||
impure fn write_str(str s);
|
||||
impure fn write_int(int n);
|
||||
impure fn write_uint(uint n);
|
||||
|
@ -242,6 +243,9 @@ fn uint_to_le_bytes(uint n, uint size) -> vec[u8] {
|
|||
}
|
||||
|
||||
state obj new_writer(buf_writer out) {
|
||||
fn get_buf_writer() -> buf_writer {
|
||||
ret out;
|
||||
}
|
||||
impure fn write_str(str s) {
|
||||
out.write(_str.bytes(s));
|
||||
}
|
||||
|
@ -262,6 +266,11 @@ fn uint_to_le_bytes(uint n, uint size) -> vec[u8] {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: Remove me once objects are exported.
|
||||
fn new_writer_(buf_writer out) -> writer {
|
||||
ret new_writer(out);
|
||||
}
|
||||
|
||||
fn file_writer(str path, vec[fileflag] flags) -> writer {
|
||||
ret new_writer(file_buf_writer(path, flags));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue