2. 练习

mod.rs

pub mod user_model;

user.rs

#[derive(Debug)]
pub struct UserModel {
    pub user_id: i32,
    pub user_name: String,
    pub user_age: u8,
    pub user_tags: [&'static str;5]
}

pub fn new_user_model()->UserModel{
    UserModel{
        user_id: 0,
        user_name: String::new(),
        user_age: 0,
        user_tags: ["";5]
    }
}

main.rs

最后更新于