X-Git-Url: https://piware.de/gitweb/?p=learn-rust.git;a=blobdiff_plain;f=src%2Fmain.rs;fp=src%2Fmain.rs;h=c07c4051165861365a2176a3c1edec6957d16903;hp=441cc79a44db49e65227afdacfa575de42e96fb9;hb=dad4fd7e6684ffa911c1298e374a56d63a56710e;hpb=80e4d9aff6de0cdeaedc8db269a18c6da91d0239 diff --git a/src/main.rs b/src/main.rs index 441cc79..c07c405 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ mod word_utils; use std::collections::HashMap; use std::io::{prelude::*, ErrorKind}; -use std::fs::File; +use std::fs::{self, File}; use word_utils::{first_word, second_word}; @@ -108,6 +108,12 @@ fn test_files() { Ok(s) => println!("Cargo.toml contents:\n{}\n-------------", s), Err(e) => println!("Could not open Cargo.toml: {:?}", e) } + + // using std API + match fs::read_to_string("Cargo.toml") { + Ok(s) => println!("Cargo.toml contents:\n{}\n-------------", s), + Err(e) => println!("Could not open Cargo.toml: {:?}", e) + } } fn main() {