From c6bc3521f1bf6367e963576e0b76baba677ed79b Mon Sep 17 00:00:00 2001 From: Luyun Xie Date: Tue, 22 Oct 2013 23:38:36 +0800 Subject: [PATCH] fix 'extra::fileinput' documentation --- src/libextra/fileinput.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libextra/fileinput.rs b/src/libextra/fileinput.rs index 8f176d5ccea13..fb3f06ad65bf2 100644 --- a/src/libextra/fileinput.rs +++ b/src/libextra/fileinput.rs @@ -36,13 +36,13 @@ of `"-"` to `stdin`. In many cases, one can use the `input_*` functions without having to handle any `FileInput` structs. E.g. a simple `cat` program - for input |line| { + do input |line| { io::println(line) } or a program that numbers lines after concatenating two files - for input_vec_state(make_path_option_vec([~"a.txt", ~"b.txt"])) |line, state| { + do input_vec_state(make_path_option_vec([~"a.txt", ~"b.txt"])) |line, state| { io::println(format!("{}: %s", state.line_num, line)); } @@ -72,10 +72,11 @@ input, skips the current file and then numbers the remaining lines (where the numbers are from the start of each file, rather than the total line count). - let input = FileInput::from_vec(pathify([~"a.txt", ~"b.txt", ~"c.txt"], - true)); + let input = FileInput::from_vec( + make_path_option_vec([~"a.txt", ~"b.txt", ~"c.txt"], true) + ); - for input.each_line |line| { + do input.each_line |line| { if line.is_empty() { break } @@ -87,7 +88,7 @@ total line count). if io::stdin().read_line() == ~"yes" { input.next_file(); // skip! - for input.each_line_state |line, state| { + do input.each_line_state |line, state| { io::println(format!("{}: %s", state.line_num_file, line)) }