Rust Programming Tutorial #21 - Impl Keyword (Implementation)

preview_player
Показать описание
In this video we take a look at the 'impl' keyword in Rust.

We see how we can add methods to a struct to make it really simple and easy to use.

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
Рекомендации по теме
Комментарии
Автор

These videos are killer. I’m about to graduate with a bachelors in computer science and a minor in mathematics. I’ve written code in many languages. I’ve spent maybe 8 months studying Rust on and off and these videos by far have explained more to me than any others. Thank you! Keep it up!

joe
Автор

Thank you so much for making these videos! I really want to see Rust being used more and you’re making a great contribution to the community.

maganaluis
Автор

Thank you, It's so much clearer to me now

exoticcoder
Автор

this is by far the best explanation on impl keyword on the whole platform. thanks you so much for your hard work.

QmVuamFtaW
Автор

So . . . Is there no bespoke "return" keyword in RUST? The function just returns as soon as a single line results in a calculation? What if there were another calculation right after?

Shakespeare
Автор

You never use strings in your structs and for some reason, when I try to use them I get an error? I can't use str and there also doesn't seem to be str8, str32, etc.

tony
Автор

It's called "implementation"; I suggest you call the actual words instead of the shortcuts so others can learn from you. Nice and straightforward tutorial, thank you!

nahiyanalamgir
Автор

How comes there is no "return" keyword in function "is_square"?

stefanosmandalas
Автор

may i ask WHY line 12 returns that value ? what if i write that line twice, or what if i want to return False anyway ?

vornamenachname
Автор

There's no return keyword for struct methods?

chenjus
Автор

Rust: when python and c++ have a child

fabionr
Автор

may be you could have added method with params like
impl Rectangle {
fn print_desc(&self) {
println!("Rectangle {} x {}", self.w, self.h);

}
fn calculate_area_of_rect(&self) {
println!("Area of Rectangle {} ", (self.w * self.h));
}


fn calculate_with_params(&self, w: i32, h: i32) {

println!("Area of Rectangle {} ", (w * h));
}
}
just to pass extra parameter if needed

dhirajkatekar
Автор

it's like class method on python xD
I tot u meant it as dictionary

ItzShinePlayz