From 27af298f1d5a227daccc834f1afbfd100aa6df37 Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Mon, 10 Feb 2020 23:13:19 +0100 Subject: [PATCH] Initial Commit --- .gitignore | 2 ++ Cargo.lock | 6 ++++++ Cargo.toml | 7 +++++++ src/main.rs | 21 +++++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..53eaa21 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..13e7699 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "eof" +version = "0.1.0" + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..673cf9b --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "eof" +version = "0.1.0" +authors = ["Joakim Hulthe "] +edition = "2018" + +[dependencies] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..9eb2af7 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,21 @@ +use std::io::{self, Write}; + +fn main() { + let stdin = io::stdin(); + let mut stdout = io::stdout(); + + let mut lines: Vec = vec![]; + loop { + let mut buf = String::new(); + stdin.read_line(&mut buf) + .expect("Could not read from stdin"); + if buf == "EOF\n" { + break; + } + lines.push(buf); + } + for line in lines { + stdout.write(line.as_bytes()) + .expect("Could not write to stdout"); + } +}