Rust: Generics, Traits, Lifetimes

Поділитися
Вставка
  • Опубліковано 7 лют 2025

КОМЕНТАРІ • 59

  • @johnyepthomi892
    @johnyepthomi892 2 роки тому +7

    It’s people like you that will increase rust adoption. Thank you for this style of explanation. Very concise and clear with examples.

  • @tylerhanson133
    @tylerhanson133 2 роки тому +52

    Very helpful. It's hard to find detailed videos on Rust by experienced engineers in it.

    • @ccgarciab
      @ccgarciab 2 роки тому +3

      Look up Jon Gjengset

    • @michaelshort2388
      @michaelshort2388 Рік тому

      not a video, but you can also find the explanation in the rust book. :)

  • @martinbecker1069
    @martinbecker1069 2 роки тому +5

    This was super helpful! Whilst I've always understood the lifetimes concept but I've always struggled to grok the lifetime syntax.
    This was a massive help in understanding it, thank you!

  • @krome305
    @krome305 2 роки тому +2

    This is the best and detailed tutorial about Generics, Traits and Lifetimes that I've found, thank you!

  • @bla_blub
    @bla_blub 2 роки тому +8

    15:54 The generic form implies, that item 1 and item2 are of exactly the same type, while the function on line 36 can have arguments of two different types, as long as they implement Summary. Notify needs a second generic.

  • @bsd0daemon
    @bsd0daemon 2 роки тому +1

    This was really good. It covers things I feel I already know, but each time it is covered, it is like learning it again. It solidifies the knowledge. I guess I never really knew the Elision rules so was always a bit confused about when I need to specify explicit lifetimes.
    The quote "lifetimes are very much a tool to get rid of dangling pointers" really stuck with me. I felt like I knew that but I guess not that well, but it is now in the forefront of my mind.

  • @antoniong4380
    @antoniong4380 Рік тому +5

    For those who haven't figured when to employ monomorphism or polymorphism yet, if you ever feel like the binary size might go crazy big due to monomorphization and you want to keep it small, use the Dyn keyword, and sacrifice some runtime performance so you can get smaller binary.
    How can you know when it might go crazy big? (Might be wrong, but I shouldn't be far)
    if your function has 1 Generics, the max amount of variants for that specific function is X^1, where X is the all the types that you used the generic function with. For example, you use the generic function with f64 and i64, you will get 2 variants.
    if you use a Function with 4 generics, the max amount of variants that might be generated is X^4.
    So if you ever feel constrained by binary size, fixing monomorphization on generics might be a place you want to look to fix.

  • @fallow64
    @fallow64 2 роки тому

    Thank you so much for including the specific chapter in the rust handbook!

  • @joeystenbeck6697
    @joeystenbeck6697 2 роки тому +2

    Hey Riki! (Ricki, Ricky, …?) Awesome videos. You explain things in a very clear and engaging way. I look forward to watching more of your Rust videos. I have a small suggestion- when pasting something (e.g., the generic version at time: 2:57), I think it may be helpful to not delete the nongeneric code in the process, so that generic and nongeneric can be compared side-by-side. Thanks for making these, they’re great!
    - Joey

  • @dulranga_2
    @dulranga_2 2 роки тому +4

    keep posting videos. I really like them!!

  • @rmvlvs5228
    @rmvlvs5228 Рік тому

    *THIS VIDEO IS SPECTACULAR AND EVERYONE SHOULD WATCH IT*

  • @PatrickLemiuex
    @PatrickLemiuex 2 роки тому

    you are great annunciator. very clearly explained and easy on the ears

  • @SavagePlay
    @SavagePlay Рік тому

    thank you this was very helpful with detail explanation pls never stop making more

  • @jacksystems
    @jacksystems 2 роки тому

    Awesome video. You teach very well, and this really made generics "click" with me. Thanks.
    I believe I was your 1,000th subscriber too!

  • @bjugdbjk
    @bjugdbjk 2 роки тому

    Fantastic man, Really enjoying the playlist, can see the difference how experiences programmers talk about and explain the concepts of rust !! really looking for the next !!
    Could you do a dedicated video on static generic lifetimes !!

  • @yotubecreators47
    @yotubecreators47 Рік тому

    Wow this is perfect explanation for me, except Lifetimes explanation seems was for advanced Rustlers, thanks a lot

  • @李晧暐
    @李晧暐 2 роки тому

    Thank you! You explain everything well!

  • @danraine9009
    @danraine9009 2 роки тому

    Thank you for this video, learned a lot and opened my mind to more possibilities for coding solutions :)

  • @topcivilian
    @topcivilian 2 роки тому

    Excellent video, my friend. Very informative.
    The google algorithm brought me here.
    You just got a new subscriber.
    Looking forward to more content like this.

  • @JessRasmussen-b1m
    @JessRasmussen-b1m 2 роки тому

    Thanks a bunch, great video!

  • @AMusset
    @AMusset Рік тому

    Thank you for the video. You got a new sub!
    Which extension are you using to see scopes with the yellow line?

  • @prashlovessamosa
    @prashlovessamosa Рік тому

    Thank you

  • @steffahn
    @steffahn 2 роки тому +1

    Something about the shape of the U!? No, man, it's just the next letter in the alphabet after T. 😅
    (Similarly, S is common because it's the letter before T.)
    Admitted, the similarity of U and V might be a reason why R, S, T could be preferred over T, U, V if you need more types; though for very many single-letter types it can also make sense to start with A, B, C, to have more room in the alphabet, or use T1, T2, T3, if you like numbers.

  • @flipper71100
    @flipper71100 2 роки тому

    It was a wonderful video I totally get the concept of generics and trait, however some part of the lifetimes are still not clear to me.

  • @paulycdong
    @paulycdong 2 роки тому +1

    Great job! You probably have already covered this somewhere else but I really like the extension in your VS Code that highlights the brackets location. Can you share the name? Thank you!😊

    • @necromeo-dev
      @necromeo-dev Рік тому +1

      In case you're still looking. It's built into VS Code itself. Look for bracket pair guides in the editor config.

    • @mariozulmin
      @mariozulmin 11 місяців тому

      @@necromeo-dev thx, was looking for that, right in the moment

  • @johnstorm589
    @johnstorm589 Рік тому

    Mind-bending, but useful!

  • @agungokill
    @agungokill 2 роки тому

    ayt, this is very nice and brief explanation

  • @b1chler
    @b1chler 2 роки тому

    Cool stuff! Thanks

  • @MohammadRajablooloverajabloo
    @MohammadRajablooloverajabloo 2 роки тому

    Thank you. what is the solution for `longest` in 26:05 (returning a dropd value), I encounter this problem and couldn't find the best solution.

  • @aodhai
    @aodhai 6 місяців тому

    U is also the next letter in the alphabet after T

  • @jameszack7158
    @jameszack7158 Рік тому

    How would you ever create an application in a non-object-oriented programming language? It seems impossible. You need those handy classes, methods, properties and encapsulations...

  • @curioSEOty
    @curioSEOty 2 роки тому +1

    trying to fix 5:11 but it gives out more and more errors. would've been nice to see the stuff running before you moved on to the next thing

    • @bertybates705
      @bertybates705 2 роки тому

      ua-cam.com/video/JLfEiJhpTbE/v-deo.html

  • @oakwizard9391
    @oakwizard9391 5 місяців тому +1

    This is lifted straight from the Rust book unfortunately. I was looking for a different take to reinforce my learning.

    • @osgiliath_burns
      @osgiliath_burns 5 місяців тому

      every top rust video is its ridiculous

  • @mazinayman4004
    @mazinayman4004 Рік тому

    Which colorscheme you use?

    • @TheDevMethod
      @TheDevMethod  Рік тому

      I switch off between a couple. I use GitHub Dark High Contrast but this video might be GitHub Dark without the High Contrast.

  • @lucasfkam
    @lucasfkam Рік тому

    What is the name of the fonttype you are using in this video?

    • @TheDevMethod
      @TheDevMethod  Рік тому

      I love using Blex Mono Nerd Font. It's a patched version of Plex Mono by IBM's Carbon deign

  • @overclucker
    @overclucker 11 місяців тому

    T stands for c++ Template, haha. The first example is one step away from a linear sort.

  • @_luisgerardo
    @_luisgerardo 2 роки тому

    Good

  • @malusmundus-9605
    @malusmundus-9605 Рік тому

    Ah it's c++ templates again... for when void* isn't good enough. Except, it's not a void pointer in the way it functions... this is function overloading.

  • @HariRoshan93
    @HariRoshan93 2 роки тому

    Love it

  • @jonathanmoore5619
    @jonathanmoore5619 2 роки тому

    I'll do what I want to do.

  • @backupmemories897
    @backupmemories897 2 роки тому

    its like template at c++ i see

  • @mrlucmorin
    @mrlucmorin Місяць тому

    Please, don’t add background music to teaching videos. It’s distracting.

  • @SpeckyYT
    @SpeckyYT 2 роки тому

    Right, do not duplicate your code! Better create a macro that duplicates it for you 😂

  • @dragonmax2000
    @dragonmax2000 2 роки тому +1

    Quite a bit of detail is missing. The video does go into some detail, but a bit shallow. I would have expected to see unit tests and implementations that are complete. Please keep it going, but add some more additional context. Thank you!

  • @matthiasg4843
    @matthiasg4843 Рік тому +1

    Did you just copy the code examples 1:1 from Let's Get Rusty?

    • @TheDevMethod
      @TheDevMethod  Рік тому +3

      The examples are from the Rust Programming Book. The link is in the description if you would like to take a look and follow along.

    • @matthiasg4843
      @matthiasg4843 Рік тому

      @@TheDevMethod Sorry for the misunderstanding. I watched 2 vids after another and saw the same code examples

  • @dmm10000
    @dmm10000 2 роки тому

    "Borrowed" is an utterly confusing stupid term - wouldnt a simple "out of scope" be much better