← Back to Gists

Read whole file

📝 Rust
rodgersjennifer232
rodgersjennifer232 · Level 9 ·

Read a file's entire contents into a String with std::fs::readtostring.

Rust
use std::fs; fn main() { let contents = fs::readtostring("example.txt").expect("Failed to read file"); println!("{}", contents);
}

Comments

No comments yet. Start the discussion.