user_input_with_autocomplete

Crates.iouser_input_with_autocomplete
lib.rsuser_input_with_autocomplete
version0.1.2
sourcesrc
created_at2021-12-16 10:05:24.719254
updated_at2021-12-17 08:04:49.61843
descriptionThe only purpose of this crate is to provide easy functionality to accept input from user, with an optional support for auto-complete of provided with a function
homepage
repository
max_upload_size
id499109
size26,807
Nishant Joshi (NishantJoshi00)

documentation

README

User Input with autocomplete

This crate provides a way to get user input with autocomplete optional auto complete functionality. Very simple to use, and parsing the input is done in a very simple way.

Usage

To use this crate you need to add the following to your Cargo.toml:

[dependencies]
user_input_with_autocomplete = "*" # or just copy the current crate version number istead of *

To use it in the code, you need to import the user_input_with_autocomplete crate:

use user_input_with_autocomplete::input::UserInput;

Then you can use the UserInput struct to get user input:

// Example
fn main() {
    let a = UserInput::new("Enter a number: ", None); // Here the first argument to the constructor of the struct is the prompt, and the second argument is to use auto-complete or not.
    // To use the auto-complete feature instead of None, you need to provide a function of the following type
    // ```Some(fn(String) -> String)```
    let b = a.to_string();
    let c: i32 = a.parse().unwrap(); // It's simple to parse the input and you can even parse it as a vector of strings or specified type, seperated by spaces.

}

Features

  • autocomplete - This feature enables the auto-complete feature.

License

MIT

Contributing

Feel free to open an issue, submit a pull request or make a suggestion.

Commit count: 0

cargo fmt