Crates.io | user_input_with_autocomplete |
lib.rs | user_input_with_autocomplete |
version | 0.1.2 |
source | src |
created_at | 2021-12-16 10:05:24.719254 |
updated_at | 2021-12-17 08:04:49.61843 |
description | The 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 | |
id | 499109 |
size | 26,807 |
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.
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.
}
autocomplete
- This feature enables the auto-complete feature.MIT
Feel free to open an issue, submit a pull request or make a suggestion.