scanln

Crates.ioscanln
lib.rsscanln
version0.1.1
sourcesrc
created_at2019-06-06 22:59:37.800875
updated_at2020-05-14 09:41:28.191223
descriptionThe inverse of println
homepagehttps://forge.typ3.tech/charles/scanln
repositoryhttps://forge.typ3.tech/charles/scanln
max_upload_size
id139513
size17,029
Charles Hall (CobaltCause)

documentation

https://docs.rs/scanln

README

scanln

The inverse of println


Overview

scanln is a macro that reads a line from stdin, removes the trailing newline (if present), and leaves other whitespace intact. It expands to an expression that returns a String, so it can be assigned to a variable or used directly. scanln may take arguments like those to the print macro, which can be used to generate a prompt.

Examples

Simple prompt

let input = scanln!("> ");

This results in a prompt that looks like this (where _ represents where the user will start typing):

> _

No prompt

let input = scanln!();

Result:

_

Formatted prompt

let input = scanln!("{}", 0);

Result:

0_
Commit count: 0

cargo fmt