[][src]Enum aoc_utils::BufferedInput

pub enum BufferedInput {
    File(BufReader<File>),
    Stdin(BufReader<Stdin>),
}

Wraps the input source to an AOC problem. Handles cmdline arguments.

Supports input from a given file as well as from STDIN. Implements std::io::BufRead for the convenience of the BufRead::lines iterator.

Example

If your executable is named prog and the description is "Example description", then the help (prog --help) will look like this:

Example description

USAGE:
    prog [FILE]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

ARGS:
    <FILE>    Input file (defaults to STDIN if not provided)

Variants

Implementations

impl BufferedInput[src]

pub fn parse_args(description: &str) -> Result<Self>[src]

Parse cmdline arguments and create a new object to read lines from an arbitrary input source.

The application optionally expects a path argument that specifies the file to read from. If not present, the input is read from STDIN.

Arguments

  • description - provides an "about" section in the usage manual.

Example

use std::io::BufRead;
use aoc_utils::BufferedInput;

let input = BufferedInput::parse_args("Example solution").unwrap();
let lines: Vec<String> = input.lines().map(Result::unwrap).collect();

pub fn unwrapped_lines(self) -> impl Iterator<Item = String>[src]

Returns an iterator over the lines of the input that panics when an error occurs.

Trait Implementations

impl BufRead for BufferedInput[src]

impl Read for BufferedInput[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.