ds-learn-rust 0.1.1

Code that I wrote while learning Rust from the Rust Book
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::fs::File;
use std::io;
use std::io::Read;

fn read_from_file() -> Result<String, io::Error> {
    let mut file = File::open("Cargo.toml")?;
    let mut content = String::new();
    file.read_to_string(&mut content)?;
    Ok(content)
}

pub fn ch_09_01() {
    let content = read_from_file().unwrap(); //.expect("Could not read the contents of the file");
    println!("{:?}", content);
}