cnsl

cnsl is a crate for writing to the standard output, standard error, and reading from standard input.\ This crate is lightly coded, and also requires no external dependencies.

Rust Build Status


Usage

readln macro


rust // without a prompt ```rust use cnsl::readln;

fn main() { println!("What is your name?"); let name = readln!(); println!("Hello, {}!", name); }

```

rust // with a prompt ```rust use cnsl::readln;

fn main() { let name = readln!("Enter your name: "); println!("Hello, {}!", name); }

```

rust // with a formatted prompt // note: defaults are not actually supported, this is just a demonstration ```rust use cnsl::readln;

const DEFAULT_AGE: u8 = 18;

fn main() { let ageinput = readln!("Enter your age (default {}): ", DEFAULTAGE);

let age = if age_input.is_empty() {
    DEFAULT_AGE
} else {
    age_input.parse::<u8>().expect("invalid input for age")
};

} ```

Information

License

This software is licensed under the WTFPL.

Contributors