Skip to content

Instantly share code, notes, and snippets.

@teru01
Created October 15, 2020 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teru01/b1b8b23a26ebc4f7940828ae8e6a61df to your computer and use it in GitHub Desktop.
Save teru01/b1b8b23a26ebc4f7940828ae8e6a61df to your computer and use it in GitHub Desktop.
use std::io;
use std::io::Read;
use std::fs::File;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
read_username_from_file()?;
Ok(())
}
fn read_username_from_file() -> Result<String, io::Error> {
let mut s = String::new();
File::open("hello.txt")?.read_to_string(&mut s)?;
Ok(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment