mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 12:36:35 +03:00
stdlib: Provide a function to extract the underlying buf_writer from a writer
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user