Read File Contents In Rust

[Solved] Read File Contents In Rust | Rust - Code Explorer | yomemimo.com
Question : read file contents in rust

Answered by : bijay-poudel

use std::fs;
fn main() { let data = fs::read_to_string("file_name.txt").expect("Unable to read file"); println!("{}", data);
}

Source : | Last Update : Mon, 20 Sep 21

Question : read file Rust

Answered by : ahmad-khaefi

use std::fs;
fn main() { let content = match fs::read_to_string("Cargo.toml") { Result::Ok(value) => value, Result::Err(error) => panic!("{}", error) }; println!("{}", content)
}

Source : | Last Update : Thu, 09 Jun 22

Answers related to read file contents in rust

Code Explorer Popular Question For Rust