rust-learning 0.1.0

Rust learning
Documentation
// 在作用域中增加 use 和路径类似于在文件系统中创建软连接(符号连接,symbolic link)。
// 注意 use 只能创建 use 所在的特定作用域内的短路径。
use rust_learning::enum_match::{enum_def, option_def, match_def, if_let_def};

use rand::Rng;

use rust_learning::base_theory::{control_flow, data_types, function, variable};

use rust_learning::{collect, enum_match, ownership, panic, type_trait_life};
use rust_learning::pub_use;

// use crate::type_trait_life::Summary;
// use crate::type_trait_life::Summary;
// 唯一的区别是 trait 必须和类型一起引入作用域以便使用额外的 trait 方法。

// Trait 作用域:use type_trait_life::Summary 使编译器识别方法实现。
use rust_learning::type_trait_life::{Summary, Tweet};

use rust_learning::struct_def;

fn main() {
    // rust_learning::hello_world::hello_world();
    // rust_learning::guess::guess_number();
    // variable::variable_immutable();
    // variable::constants();
    // variable::shadowing();
    // let res = data_types::data_types();
    // data_types::number_compute();
    // function::function(5);
    // println!("res = {}", function::return_function(4));
    // control_flow::control_if();
    // control_flow::control_loops();
    // ownership::ownership();
    // ownership::ownership_function();
    // ownership::ownership_reference();
    // ownership::ownership_mutable_reference();
    // ownership::ownership_dangling_reference();
    // ownership::owner_slice();
    // struct_def::struct_def();
    // struct_def::tuple_struct();
    // struct_def::struct_method();
    // enum_def::enum_def();
    // enum_def::enum_struct();
    // option_def::option_use();
    // match_def::match_def();
    // match_def::option_match();
    // match_def::match_other();
    // if_let_def::if_let();
    // pub use的使用方式,
    // 将 operations 模块中的 add 和 subtract 函数重新导出到 pub_use 模块的作用域中。
    // 重导出:使用 pub use 可以将某个模块中的项重新导出到当前模块的作用域中,使得这些项可以在其他地方直接引用。
    // 简化路径:通过 pub use,你可以为用户提供一个更简洁的路径来访问某些功能,而不必让他们知道内部模块的具体结构。
    // 举例:
    // 重导出: 把operation模块中的add、subtract导入到pub_use
    // 简化路径: 只需要通过pub_use::add就可以使用。
    // pub_use::add(1, 2);
    //
    // collect::vector_def();
    // collect::string_def();
    // collect::hashmap_def();
    //
    // panic::panic_def();
    // panic::result_def();
    // panic::result_unwrap();
    // panic::result_expect();
    // panic::result_propagating_panic();
    //
    // type_trait_life::get_largest();
    // type_trait_life::struct_type();
    //
    // type_trait_life::trait_def();
    //
    // let tweet = Tweet::new("1".to_string(), "2".to_string());
    // println!("1 new tweet: {}", tweet.summarize());
    // tweet.print_content();
    //
    //
    // type_trait_life::trait_as_param();
    //
    // type_trait_life::lifetime_demo();
}