Crate grabinput [] [src]

This library really is intended to be dirt simple. It doesn't do much--just allows you to skip some typing when you want to read something. Like, say you want to write a program to add up all the integers in a file...

extern crate grabinput;

let sum: i32 = grabinput::from_args().with_fallback()
    .filter_map(|n| n.trim().parse::<i32>().ok())
    .sum();

That's your whole program now. I thought about having the library trim newlines from the end of each line, because .NET's similar library functions will do that, but I guess I just figured it was faster to let the user decide--no reason to make them pay for the work if they don't care if it's done or not, right? Anyway...

Structs

FromFile

FromFile provides a convenient wrapper for an optional file.

FromStdin

FromStdin wraps a buffered Stdin.

WithFallback

WithFallBack wraps an optional file stream and standard input stream.

Functions

from_args

Creates an input handle based on std::env::args().nth(1).

from_optional_path

Creates an input handle based on an optional path.

from_path

Creates an input handle based on the provided path.

from_stdin

Creates an input handle based on standard in.