Skip to content

Instantly share code, notes, and snippets.

@sebastian-navarro
Created April 20, 2024 02:28
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 sebastian-navarro/258f9388cea36c00cc9ecc39700de036 to your computer and use it in GitHub Desktop.
Save sebastian-navarro/258f9388cea36c00cc9ecc39700de036 to your computer and use it in GitHub Desktop.
Read file in Rust
use std::fs;
use std::io;
fn main() -> io::Result<()> {
let file_contents = fs::read_to_string("info.txt")?;
println!("info.txt content =\n{file_contents}");
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment