scanln 0.1.1

The inverse of println
Documentation
  • Coverage
  • 40%
    2 out of 5 items documented1 out of 1 items with examples
  • Size
  • Source code size: 16.5 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.08 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • CobaltCause

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_