#[derive(Debug)]
struct Rusty{ is_rust: bool,
is_awesome: bool
}
impl Rusty{
fn boo(){
println!("Boo!");
}
fn check_rust(&self){
if self.is_rust == true {println!("Is Rust");} }
}
#[derive(Debug)]
pub struct Rectangle{
pub width: u32,
pub height: u32
}
impl Rectangle{
fn calc(&self) -> u32{
self.width * self.height
}
pub fn can_hold(&self, other: &Rectangle) -> bool{
self.width > other.width && self.height > other.height
}
}
impl Rectangle{
fn square(size: u32) -> Rectangle{
Rectangle{width: size, height: size}
}
}
pub fn main(){
let var = Rusty{is_rust: true, is_awesome: true}; println!("isRust: {}\nisAwewsome: {}", var.is_rust, var.is_awesome);
let var2 = Rusty{is_rust: false, ..var}; println!("{:#?}", var2);
struct Color(i32, i32, i32);
let black = Color(0, 0, 0);
let rect = Rectangle{width: 40, height: 50};
println!("The area of rectangle: {}", rect.calc());
let rect1 = Rectangle{
width: 10,
height: 40
};
println!("Rectangle can hold rect1: {}", rect.can_hold(&rect1));
let sq = Rectangle::square(10);
println!("Square: {:#?}", sq);
}