ask_input 0.2.0

Simple input library
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented2 out of 2 items with examples
  • Size
  • Source code size: 5.63 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 242.74 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • FelineFantasy/ask_input
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • FelineFantasy

ask_input ⌨️

Rust Version License docs.rs

A micro-library for keyboard input in Rust. No extra code β€” just input and get values!

πŸ“ Description

ask_input is a tiny wrapper over Rust's standard I/O. One function. All types. Rust figures out the type automatically.

Features:

  • 🎯 One function for everything
  • 🧠 Smart type detection
  • ⚑ Zero dependencies

βš™οΈ Installation

Π”ΠΎΠ±Π°Π²ΡŒΡ‚Π΅ Π² ваш Cargo.toml:

[dependencies]

ask_input = "0.2.0"

πŸ§ͺ Examples

Basic usage with proper error handling:

use ask_input::input;

fn main() {
    let age: i32 = input().expect("Failed to read age");
    let price: f64 = input().expect("Failed to read price");
    let name: String = input().expect("Failed to read name");
    
    println!("Age: {}, Price: {}, Name: {}", age, price, name);
}

πŸ“¦ Functions

  • input::<T>() β€” Input any type (i32, f64, String, etc.)

πŸ“‹ Supported Types

Type Example Notes
i32 42 Leading/trailing whitespace trimmed
f64 3.14 Leading/trailing whitespace trimmed
String Hello Whitespace preserved (only newline removed)
bool true Case-sensitive, whitespace trimmed
i64, u32... Any numeric Whitespace trimmed

⚠️ Breaking Changes (v0.1.0 β†’ v0.2.0)

  • int_input() β†’ input::<i32>()
  • float_input() β†’ input::<f64>()
  • str_input() β†’ input::<String>()
  • Now returns Result instead of panicking

πŸ‘€ Author

  • FelineFantasy
  • License: MIT