hs-rust-learn 0.1.0

hs's rust test learn
Documentation
#[derive(Debug)]
struct User {
    username: String,
    email: String,
    sign_in_count: u64,
    active: bool,
}

#[derive(Debug)]
struct Rect {
    width: u32,
    height: u32,
}

impl Rect {
    fn area(&self) -> u32 {
        self.width * self.height
    }

    fn in_area(&self, other: &Rect) -> bool {
        self.width > other.width && self.height > other.height
    }
}

fn area(rect: &Rect) -> u32 {
    rect.width * rect.height
}



fn main () {
    let rect = Rect {
        width: 30,
        height: 50,
    };
    
    println!("The area of the rectangle is {} square pixels.", area(&rect));

    println!("The size of the rectangle is {} square pixels.", rect.area());

    let rect2 = Rect {
        width: 10,
        height: 40,
    };
    println!("rect2 in rect? {}", rect.in_area(&rect2));

    // let mut user = User {
    //     email: String::from("abc@123.com"),
    //     username: String::from("abc"),
    //     active: true,
    //     sign_in_count: 1,
    // };
    // println!("{:#?}", user);
    // user.email = String::from("abc@zhihu.com");
    // println!("{:#?}", user);

    // let user1 = User {
    //     email: String::from("user@abc.com"),
    //     ..user
    // };
    // println!("{:#?}", user1);
}

struct Color(i32, i32, i32);
struct Point(i32, i32, i32);