rsteract 0.1.0

From stdin to String and back to stdout
Documentation
  • Coverage
  • 0%
    0 out of 5 items documented0 out of 2 items with examples
  • Size
  • Source code size: 15.57 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 260.94 kB 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: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • alepez/rsteract
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • alepez

rsteract

A clone of Haskell interact function.

The interact function takes a function of type Fn(String) -> String as its argument.

The entire input from the standard input device is passed to this function as its argument, and the resulting string is output on the standard output device.

Example

If this is your_program:

use rsteract::stdio::interact;

fn main() -> Result<(), std::io::Error> {
    interact(|x| x.chars().rev().collect())
}
❯ echo 1234 | your_program
4321

This crate also provide a generic version for Read and Write traits.

Use cases

Competitive programming, when you need to quickly write code to read from stdin and write to stdout.

Feel free to copy this your code in your program, if using external crates is not an option.