Skip to content

Instantly share code, notes, and snippets.

@RGGH
Created December 1, 2022 14:44
Show Gist options
  • Save RGGH/0de3e6e91d416de9d17c67d6ed6bf608 to your computer and use it in GitHub Desktop.
Save RGGH/0de3e6e91d416de9d17c67d6ed6bf608 to your computer and use it in GitHub Desktop.
use std::fs;
fn main() {
let results = fs::read_to_string("mytext.txt");
let contents = match results {
Ok(messag) => messag,
Err(error) => String::from("Uh oh"),
};
println!("{}", contents);
}
@RGGH
Copy link
Author

RGGH commented Dec 1, 2022

Read text file with rust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment