in 1.0.2

Python's input() for Rust
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 0 items with examples
  • Size
  • Source code size: 2.87 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.05 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • rtificr/in
    0 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • rtificr

in

A simple Rust crate that provides Python-style input functions through macros.

Installation

Add this to your Cargo.toml:

[dependencies]
in = "1.0.1"

Usage

This crate provides two macros:

  • input!(): Get user input on the same with an optional prompt
  • inputln!(): Same as input!() but user input is taken on the next line

Examples

use in::input;
use in::inputln;

fn main() {
    let a: String = input!();
    // Enter a number: x
    let x = input!("Enter a number: ").parse::<f32>().unwrap();

    // Enter a number:
    // x
    let y = inputln!("Enter a number: ").parse::<f32>().unwrap();
    
    // x
    let z = input!().parse::<f32>().unwrap();

    println!("x = {x}");
}

License

This project is licensed under the MIT License.