Simple console input macros with the goal of being implemented in the standard library.

Related tags

Command-line scanio
Overview

scanio

RFC: https://github.com/rust-lang/rfcs/pull/3183

This crate is the testing/WIP implementation of some simple macros for generic text input scanning (to accompany the print family of macros).

This crate currently implements four macros, scan!, try_scan!, read! and try_read!.

The implementation for these macros is experimental.

scan! usage:

#[macro_use]
extern crate scanio;

fn main() {
    let name: String;
    let age: u8;
    
    // reads a String into `name` and a u8 into `age`
    // if it fails, it will simply assign Default::default()
    scan!("{} {}", name, age);
    
    println!("{} of age {}", name, age);
}

try_scan! usage:

#[macro_use]
extern crate scanio;

fn main() {
    // returns a Result<(String, u8), ()>, which we unwrap
    let person = try_scan!("{} {}", String, u8).expect("Invalid input!");
    
    // ideally you should `match` on the result but this is an example so :shrug:
    
    println!("{} of age {}", person.0, person.1);
}

The read! and try_read! macros work exactly the same, however their first argument must be a mutable reference to an object that implements the std::io::Read trait, such as std::io::stdin() or a File.

You might also like...
Console progress bar for Rust
Console progress bar for Rust

Terminal progress bar for Rust Console progress bar for Rust Inspired from pb, support and tested on MacOS, Linux and Windows Documentation Examples s

🌈 Brings back colour console to Win64 for Garry's Mod SRCDS
🌈 Brings back colour console to Win64 for Garry's Mod SRCDS

🌈 gmsv_concolormsg This module for Garry's Mod fixes x86-64 Windows 64-bit SRCDS not displaying colours. Why does it do that? Who knows! But it's eas

Tldr - 📚 Collaborative cheatsheets for console commands
Tldr - 📚 Collaborative cheatsheets for console commands

What is tldr-pages? The tldr-pages project is a collection of community-maintained help pages for command-line tools, that aims to be a simpler, more

A panic hook for wasm32-unknown-unknown that logs panics with console.error
A panic hook for wasm32-unknown-unknown that logs panics with console.error

console_error_panic_hook This crate lets you debug panics on wasm32-unknown-unknown by providing a panic hook that forwards panic messages to console.

Wena is a micro-framework that provides an elegant starting point for your console application.
Wena is a micro-framework that provides an elegant starting point for your console application.

Wena was created by Nuno Maduro, and is a Rust Lang micro-framework that provides an elegant starting point for your console application. This project

An ascii webcam in your console, written as a way of learning rust.

asciicam An ascii webcam in your console, written as a way of learning rust. asciicam picture of me holding a basketball usage only linux is supported

scan markdown files and execute `console` blocks

exec-commands − scan markdown files and execute console blocks exec-commands is a utility to update command-line-tool examples embedded in markdown fi

Logging for text that should stay in the same place in a console.

console_static_text Crate for logging text that should stay in the same place in a console. This measures words to handle wrapping and has some consol

A blazingly fast rust-based bionic reader for blazingly fast reading within a terminal console 🦀
A blazingly fast rust-based bionic reader for blazingly fast reading within a terminal console 🦀

This Rust-based CLI tool reads text and returns it back in bionic reading format for blazingly fast loading and even faster reading! Bionic reading is

Releases(unstable)
  • unstable(Nov 15, 2021)

    | :warning: WARNING | |:--------------------------------------------------------:| | This project is incomplete and may not work as expected. |

    Source code(tar.gz)
    Source code(zip)
Owner
undersquire
Experienced C, C#, C++, Nim, Java, Rust, Python, HTML, CSS/SCSS, JavaScript/TypeScript developer.
undersquire
Rust Crate that allows to do interruptions in console. Will be implemented to functional terminal customization kit.

termpause Rust Crate that allows to do interruptions in console. Will be implemented to functional terminal customization kit. Usage Add this in your

Just Said 4 Sep 21, 2022
Js-macros - Quickly prototype Rust procedural macros using JavaScript or TypeScript!

js-macros Quickly prototype Rust procedural macros using JavaScript or TypeScript! Have you ever thought "this would be a great use case for a procedu

null 15 Jun 17, 2022
A simple crate, that protects some variables from being modified by memory tampering tools.

Crate: protected_integer A simple crate, that protects some variables from being modified by memory tampering tools. Usage Add this crate to dependenc

lihe 5 Nov 30, 2022
being Ariel's best friend!

Sebastian se·bas·tian - sɪˈbæstɪən A simple tool used to access UniMi services -- mainly ariel, but not only -- via CLI. Important: state First of all

null 2 Sep 2, 2022
Safer Nostr is a service that helps protect users by loading sensitive information (IP leak) and using AI to prevent inappropriate images from being uploaded.

Safer Nostr is a service that helps protect users by loading sensitive information (IP leak) and using AI to prevent inappropriate images from being uploaded. It also offers image optimization and storage options. It has configurable privacy and storage settings, as well as custom cache expiration.

Thomas 4 Dec 29, 2022
Umpteen is a general-purpose programming language currently in active development being bootstrapped from Rust

The Umpteen Programming Language This repository provides the reference implementation for the Umpteen Programming Language, bootstrapped from Rust. U

Katie Janzen 4 Nov 20, 2023
a chess engine written in rust. not even close to being done

Goals improve at the rust programming language. my first major project tought me how to do things in rust. I hope for this project to teach me how to

null 6 Apr 2, 2024
This library provides a convenient derive macro for the standard library's std::error::Error trait.

derive(Error) This library provides a convenient derive macro for the standard library's std::error::Error trait. [dependencies] therror = "1.0" Compi

Sebastian Thiel 5 Oct 23, 2023
A library that creates a terminal-like window with feature-packed drawing of text and easy input handling. MIRROR.

BearLibTerminal provides a pseudoterminal window with a grid of character cells and a simple yet powerful API for flexible textual output and uncompli

Tommy Ettinger 43 Oct 31, 2022
TUI input library supporting multiple backends

tui-input WARNING: Most of the functionality is only human tested. A TUI input library supporting multiple backends. This crate can be used with tui-r

Arijit Basu 36 Dec 19, 2022