saneput 0.2.0

Sane input reading library
Documentation
  • Coverage
  • 33.33%
    3 out of 9 items documented1 out of 3 items with examples
  • Size
  • Source code size: 9.02 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 500.12 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • ItsEthra/saneput
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ItsEthra

Saneput

Rust sane input reading library

Usage

# use saneput::input;
// By default type `input` parses is `i32`.
let value = input!("{}");
// > -15
// value = -15

// You can also specify the radix input string should be in. Though no prefixes are allowed.
// `b` - binary, `o` - octal, `d` - decimal(defualt), `x` - hexidecimal.
// `{:x}` - is called a group.
// Accepted types are all integers types, `f32` and `f64`.
let thing: u64 = input!("{u64:x}");
// > ff
// thing = 255

// Returns a tuple. You can enter number on the same line separated by space/tab
// > 1 2
// Or you can enter them one by one with each on a separate line.
// > 1
// > 2
let (a, b): (i32, u32) = input!("{i32}{u32}");
/*                                   ^^
                                     ||
                            Notice lack of space.
All groups must follow each other with no characters in between. */

// For more comprehensive example take a look at `examples/grid.rs`

Installation

[dependencies]
saneput = "0.1"

# For development version
saneput = { git = "https://github.com/ItsEthra/saneput" }