gw-rust-programming-tutorial 0.1.0

gw rust test.
Documentation
pub fn test_painic_fn()
{
    //panic!("crash and burn");
}

use std::fs::File;

pub fn test_panic_resume() {
    // let f = File::open("hello.txt");

    // let f = match f {
    //     Ok(file) => file,
    //     Err(error) => {
    //         panic!("Problem opening the file: {:?}", error)
    //     },
    // };

    let f = File::open("hello.txt").unwrap();
}


use std::io;
use std::io::Read;

pub fn read_username_from_file() -> Result<String, io::Error> {
    let f = File::open("hello.txt");

    let mut f = match f {
        Ok(file) => file,
        Err(e) =>{println!("ssss111"); return Err(e)},
    };

    let mut s = String::new();
    match f.read_to_string(&mut s) {
        Ok(_) => Ok(s),
        Err(e) => {
            println!("sssss");
            Err(e)},
    }
}