A simple Rust Library to easily process std input.
What is it?
This crate was a little inspired by this, so it won't have any dependencies besides the standard library, anything extra should be done by hand or cherrypicked to avoid bloating something this simple.
scanrs is a small working rust crate that makes handling user input easier.
Rust has a rather "weird" way to read std input, even though asking for user input inside terminal applications is a little outdated.
But it's neccesary in some cases or in begginer-exercises to ask for a proper input, sadly doing this in rust results in long lines of text and the end program turns very verbose.
This library just attempts to make reading standard primitive types easier which makes it faster, simple to understand and lightweight.
How to use it?
This crate doesn't have much science behind it, to it's fairly simple to use, you just call the function you wish.
One way of reading user input in rust:
One simple way to read user input in rust is by playing a little with error
handling (or using a straight
let mut number = Stringnew;
let number: f64 = match number.trim.parse ;
However this turns a little verbose when you need to read multiple variables, so you can use this crate instead.
What kind of primitive types can it handle?
Current functions available:
scann: Reads a number from stdin.
scanvec: Scans a whitespace separated list of elements
scanln: Scans a String
- Make this work with generics so functions can read ANY type.
- Make this crate colored to send fancy errors.