painless_input

Crates.iopainless_input
lib.rspainless_input
version0.1.4
sourcesrc
created_at2023-09-07 16:59:41.577005
updated_at2023-09-14 16:52:09.293478
descriptionA simple input library with support for array input, validation, and pretty error messages.
homepagehttps://github.com/AHL00/painless_input
repository
max_upload_size
id966401
size62,156
Khant Htet (AHL00)

documentation

README

Painless Input

This is an easy to use input library crate. It automatically handles parsing errors and data validation with a simple syntax and good looking error messages.

Error message:

Error

Array input:

Array

Multiselect input:

Multiselect

Select input:

Select

Usage

Normal input:

use painless_input::input;

fn main() {
    let num: u8 = input("Enter a number: ");
    println!();
}

Array input:

use painless_input::input_array;

fn main() {
    let nums: Vec<u8> = input_array("Enter a list of numbers: ");
    println!();
}

Data validation:

use painless_input::input_with_validation;

fn main() {
    let validated_num = input_with_validation::<u8>("Enter a number between 0 and 10: ", Box::new(|value| {
        if value < 0 || value > 10 {
            Err("Number must be between 0 and 10")
        } else {
            Ok(())
        }
    }));
    println!();
}

Features

  • Array input
  • Builtin data validation with custom messages
  • Pretty error messages
  • Cross platform

Dependencies

Commit count: 0

cargo fmt