Editor\'s note: This question refers to parts of Rust that predate Rust 1.0, but the general concept is still valid in Rust 1.0.
I intend to
Editor's note: This answer predates Rust 1.0. Please see the other answers for modern solutions.
In Rust 0.4, use the ReaderUtil
trait to access the read_line
function. Note that you need to explicitly cast the value to a trait type, eg, reader as io::ReaderUtil
fn main() {
let mut allLines = ~[];
let reader = io::stdin();
while !reader.eof() {
allLines.push((reader as io::ReaderUtil).read_line());
}
for allLines.each |line| {
io::println(fmt!("%s", *line));
}
}