Created
October 15, 2020 08:43
-
-
Save teru01/b1b8b23a26ebc4f7940828ae8e6a61df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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