Using Structs to Structure Related Data - Rust

preview_player
Показать описание
Chapter 5

Рекомендации по теме
Комментарии
Автор

I like your style of presentation very much. It's very easy to follow and understand what you are saying.

nachnamevorname
Автор

"Rectangle(width: 1, ..rect);" reminds me of spreading in javascript - and I like it!

nachnamevorname
Автор

Hi, thanks for the video. It's really helpful. But I have one doubt why do we need to use '&' to get the data from the rect struct passed to the can_hold function.
impl Rect {
fn area(&self) -> u32 {
// Self refers to the object which call the function
&self.w * &self.h
}
fn can_hold(&self, r: &Rect) -> bool {
&self.w > &r.w && &self.h > &r.h // This part why &r why not just r.
}
}

mathewjoseph