title: Rust reading a file
body: <p>I'm trying to read a file named <code>enable.txt</code> that's in the same dir as my <code>main.rs</code>, and my code looks like this:</p>
  
  <pre><code>use std::fs::File;
  use std::io::prelude::*;
  use std::path::Path;
  use std::error::Error;
  fn main() {
      let path = Path::new("enable.txt");
      let display = path.display();
      let mut file = File::open(&amp;path);
      let mut contents = String::new();
      file.read_to_string(&amp;mut contents);
      println!("{}", contents);
  }
  </code></pre>
  
  <p>When I compile it with either <code>cargo run</code> or <code>rustc src/main.rs</code>, I get this error message:</p>
  
  <pre class="lang-none prettyprint-override"><code>error: no method named `read_to_string` found for type `std::result::Result&lt;std::fs::File, std::io::Error&gt;` in the current scope
    --&gt; src/main.rs:10:10
     |
  10 |     file.read_to_string(&amp;mut contents);
     |          ^^^^^^^^^^^^^^
  </code></pre>