Skip to content

fix 'extra::fileinput' documentation #10017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/libextra/fileinput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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))
}
Expand Down