gw-rust-programming-tutorial 0.1.0

gw rust test.
Documentation
//在 mod front_of_house 后使用分号,而不是代码块,这将告诉 Rust 在另一个与模块同名的文件中加载模块的内容
mod front_of_house;

pub use crate::front_of_house::hosting;

pub fn eat_at_restaurant() {
    hosting::add_to_waitlist();
}

pub mod chapter_8;
pub use crate::chapter_8::test_collection;
pub use crate::chapter_8::test_string;
pub use crate::chapter_8::test_map;

pub fn test_chapter_8()
{
    test_collection::test_vec();
    test_string::test_string();
    test_map::test_hash_map();
}

//9
pub mod chapter_9;
pub use crate::chapter_9::test_panic;
pub fn test_chapter_9()
{
    test_panic::test_painic_fn();
    //test_panic::test_panic_resume();
    test_panic::read_username_from_file();
}

//10
pub mod chapter_10;
pub use crate::chapter_10::test_generics;
pub use crate::chapter_10::test_traits;
pub use crate::chapter_10::test_lifetime;
pub fn test_chapter_10()
{
    println!("=========================test chapter 10 ====================");
    let v=vec![1,5,8,1,2];
    let maxv = test_generics::test_generics_fn(&v);
    println!("max={}",maxv);
    let maxv = test_generics::test_generics_fn1(&v);
    println!("max={}",maxv);

    test_traits::test_trait_fn();

    test_lifetime::test_lifetime_fn();
}

//12
pub mod chapter_12;
pub use crate::chapter_12::cmdargs;
pub use crate::chapter_12::testfile;
pub use crate::chapter_12::test_12_4;
pub use crate::chapter_12::test_12_6;

pub fn test_chapter_12()
{
    cmdargs::test_getargs();
    testfile::test_file();
    test_12_4::test_test_driver_dev();
    test_12_6::test_err_to_stderr();
}

//13
pub mod chapter_13;
pub use crate::chapter_13::test_closure;
use crate::chapter_13::file_iterator;

pub fn test_chapter_13()
{
    test_closure::fn_closure();
    file_iterator::test_13_2();
}

// mod front_of_house {
//     pub mod hosting {
//         pub fn add_to_waitlist() {
//             println!("add_to_waitlist");
//         }

//         fn seat_at_table() {}
//     }

//     mod serving {
//         fn take_order() {}

//         fn serve_order() {}

//         fn take_payment() {}
//     }
// }

// pub fn eat_at_restaurant1() {
//     // 绝对路径
//     crate::front_of_house::hosting::add_to_waitlist();

//     // 相对路径
//     front_of_house::hosting::add_to_waitlist();
// }

// //创建公有结构体和枚举
// mod back_of_house {
//     pub struct Breakfast {
//         pub toast: String,
//         seasonal_fruit: String,
//     }

//     impl Breakfast {
//         pub fn summer(toast: &str) -> Breakfast {
//             Breakfast {
//                 toast: String::from(toast),
//                 seasonal_fruit: String::from("peaches"),
//             }
//         }
//     }
// }

// pub fn eat_at_restaurant() {
//     // 在夏天点一份黑麦面包作为早餐
//     let mut meal = back_of_house::Breakfast::summer("Rye");
//     // 更改我们想要的面包
//     meal.toast = String::from("Wheat");
//     println!("I'd like {} toast please", meal.toast);

//     // 如果取消下一行的注释,将会导致编译失败;我们不被允许
//     // 看到或更改随餐搭配的季节水果
//     // meal.seasonal_fruit = String::from("blueberries");
// }