title: How can I read user input in Rust?
body: <p>I intend to make a tokenizer. I need to read every line the user types and stop reading once the user presses <kbd>Ctrl</kbd> + <kbd>D</kbd>.</p>
  <p>I searched around and only found <a href="http://rusttutorial.blogspot.ca/2012/09/command-line-user-input-stdin.html" rel="noreferrer">one example</a> on Rust IO which does not even compile. I looked at the <code>io</code> module's documentation and found that the <code>read_line()</code> function is part of the <code>ReaderUtil</code> interface, but <code>stdin()</code> returns a <code>Reader</code> instead.</p>
  <p>The code that I would like would essentially look like the following in C++:</p>
  <pre class="lang-cpp prettyprint-override"><code>vector&lt;string&gt; readLines () {
      vector&lt;string&gt; allLines;
      string line;
  
      while (cin &gt;&gt; line) {
          allLines.push_back(line);
      }
  
      return allLines;
  }
  </code></pre>
  <blockquote>
  <p><sub>This question refers to parts of Rust that predate Rust 1.0, but the general concept is still valid in Rust 1.0.</sub></p>
  </blockquote>