<Editor\'s note: This question is for a version of Rust prior to 1.0. Some answers have been updated to cover Rust 1.0 or up, but not all.
Editor's note: This answer is for a version of Rust prior to 1.0 and does not compile in Rust 1.0.
I'm just exploring rust myself, but after searching a bit, came up with the following use of the native
crate: (using file descriptor "1" for the example -- 1 is stdout
)
extern crate native;
use native::io::file::FileDesc as FileDesc;
fn main()
{
let mut f = FileDesc::new(1, true);
let buf = "Hello, world!\n".as_bytes();
f.inner_write(buf);
}
(Tested with rustc 0.13.0-nightly
. Note that the inner_write
method may have been renamed to write
in more recent versions of libstd
)
The native
crate was recently removed from the standard library and FileDesc
, while still exists as std::sys::fs::FileDesc
is no longer public...