mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-12-28 06:49:19 +00:00
29 lines
646 B
Rust
29 lines
646 B
Rust
use std::fs;
|
|
use std::path::Path;
|
|
|
|
const TEST_FILE_NAME: &str = "SampleTextFile.txt";
|
|
fn main() {
|
|
create_required_files();
|
|
|
|
let read_str_result = fs::read_to_string(TEST_FILE_NAME);
|
|
|
|
match read_str_result {
|
|
Ok(contents) => {
|
|
// TODO : What would be the expected text ?
|
|
assert_eq!(, contents);
|
|
}
|
|
Err(_) => {
|
|
panic!("Error reading file.");
|
|
}
|
|
}
|
|
}
|
|
|
|
fn create_required_files() {
|
|
let file_path = Path::new(TEST_FILE_NAME);
|
|
|
|
if !file_path.exists() {
|
|
fs::write(file_path, "This is the file content.").unwrap();
|
|
println!("File created.");
|
|
}
|
|
}
|