rsio 0.1.0

A simple Rust IO helper library for console input
Documentation
  • Coverage
  • 66.67%
    2 out of 3 items documented2 out of 2 items with examples
  • Size
  • Source code size: 4.56 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 244.11 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: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Cnkrru/rsio
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Cnkrru

rsio

English | 中文


English

A simple Rust IO helper library for console input.

Installation

Add to your Cargo.toml:

[dependencies]
rsio = "0.1.0"

Usage

use rsio::{input, input_num};

fn main() {
    // Read a string from stdin
    let name = input();
    println!("Hello, {}", name);

    // Read a number from stdin (supports any FromStr type)
    let x: i32 = input_num();
    let y: f64 = input_num();
    println!("x + y = {}", x as f64 + y);
}

API

  • input() -> String — Reads a line from stdin, trims whitespace, and returns it as a String.
  • input_num<F: FromStr>() -> F — Reads a line from stdin and parses it into the specified numeric type.

License

MIT


中文

一个简单的 Rust 控制台输入辅助库。

安装

Cargo.toml 中添加:

[dependencies]
rsio = "0.1.0"

使用

use rsio::{input, input_num};

fn main() {
    // 从标准输入读取字符串
    let name = input();
    println!("你好, {}", name);

    // 从标准输入读取数字(支持任意实现了 FromStr 的类型)
    let x: i32 = input_num();
    let y: f64 = input_num();
    println!("x + y = {}", x as f64 + y);
}

API

  • input() -> String — 从标准输入读取一行,去除首尾空白后返回 String
  • input_num<F: FromStr>() -> F — 从标准输入读取一行并解析为指定数字类型。

许可协议

MIT