read-stdin 1.1.1

A simple and easy way reading of obtaining user input.
Documentation
  • Coverage
  • 57.14%
    4 out of 7 items documented4 out of 6 items with examples
  • Size
  • Source code size: 7.02 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.23 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • local-interloper/read-stdin
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • local-interloper

read-stdin

About

read-stdin is a small set of functions I wrote once I got sick of writing code for handling user input in a terminal so I decided to publish it online for anyone to enjoy.

Examples

You can use read_stdin to ask the user for input. This function will return a Result that will be Ok if the user enters something that successfuly parses into a generic type of your choice, and Err if it fails parsing.

use read_stdin::read_stdin;

let Ok(n) = read_stdin::<i32>() else {
println!("You entered an incorrect data type!");
return;
};

println!("You entered: {}", n)

You can also use read_stdin_util_ok if you wish to annoy the user until their data parses correctly.

use read_stdin::read_stdin_until_ok;

let n = read_stdin_until_ok::<i32>();

println!("You entered: {}", n)