Just to be clear. The compiler is doing the monomorphization. You say copy/paste at one point that might confuse one into where this happens.
@YummyRed
4 жыл бұрын
Good material, thanks.
@Melch3848
Жыл бұрын
I am learning Rust about 3 years after learning it went on my project list, and these videos are invaluable. Thank you (if you still read comments on this video!). I'm extending some OpenAPI generated code for a Docker Registry which also allows Bittorrent distribution as my learning project. I hope to eventually have something that gains traction in the world. It's insane that there is not a P2P distribution for container images, especially inside the enterprise.
@mihaigalos279
2 жыл бұрын
For the Mosquito type, I guess you can just leave out implementing the Adoptable trait. Then you don't need the "if" in maybeAdopt(), since that function cannot bind to mosquitos (since they don't implement the Adoptable trait).
@HerringtonDarkholme
4 жыл бұрын
Great talk! I wonder where I can find the slides?
@RustVideos
4 жыл бұрын
Here are the slides: docs.google.com/presentation/d/1qGrhRDUgFrnMsSm4MHO0IGozfSlNomn3mlmktWcvI5M/edit
@bjugdbjk
2 жыл бұрын
Very informative, Thank you, Really got a overview how powerful and simple the traits can do the things in rust which are little complex in other GC based langs like Java.
@dengan699
3 жыл бұрын
Clear and helpful! Thanks!
@vbmade2000
2 жыл бұрын
Informative presentation. Thanks.
@nicolasmartino7709
3 жыл бұрын
It is probably going to sound dumb but let's say I have: trait Animal{ fn get_age(&self)-> i32; } struct Cat { age: i32 } impl Animal for Cat{ fn get_age(&self)-> i32{ return self.age; } } struct Dog { age:i32 } impl Animal for Dog{ fn get_age(&self)-> i32{ return self.age; } } //How can I write a function: fn make_it_age(a:T, years:i32) -> T{ //This must return the aged animal }
@sanifairmillionaire970
2 жыл бұрын
Extend the trait with a setter method all implementors have to provide. Alternatively, the getter might return a mutable reference.
@soumen_pradhan
2 жыл бұрын
You should add a set_age(&mut self) or set_age(self) -> T to trait Animal. make_it_age() does not know how to create your Type T. It only has access to trait Animal's methods.
Пікірлер: 12