← Back to Gists

Read file to String

📝 Rust
larry_cook
larry_cook · Level 6 ·

Easily read an entire file into a String using std::fs::readtostring for simple, safe I/O in Rust.

Rust
use std::fs; fn main() -> Result<(), Box<dyn std::error::Error>> { let content = fs::readtostring("example.txt")?; println!("{}", content); Ok(())
}

Comments

No comments yet. Start the discussion.