Rust Structs, Traits and Impl

Поделиться
HTML-код
  • Опубликовано: 29 окт 2024

Комментарии • 79

  • @naavu_neevu
    @naavu_neevu 4 года назад +44

    This person is awesome.

  • @ringoffire0
    @ringoffire0 2 года назад +2

    9:10 "It's easy to get used to - _the water is warm_ "
    I might steal this

  • @ExpHPKun
    @ExpHPKun 4 года назад +13

    16:05 A correction: Only the crate that defines a type can add inherent methods to it (it is merely that you are allowed to do it in any *module* of that crate). If you want to add methods to a type in some library you depend on (or to e.g. a primitive type like i32), then you have to put them on a trait and implement it for those types (and then code that wants to use those methods must import the trait). This pattern is known as writing an "extension trait."

  • @wiktorwektor123
    @wiktorwektor123 4 года назад +7

    I was learning Rust after knowing C++ and for the first week I hated compiler because it's constant errors reporting and refusing to compile code. It's like grammar teacher but worse. It will fail your test after just one mistake. Now after 1 month I can't imagine life without Rust compiler. It's called Stocholm Syndrome? :D
    Great tutorial Doug, best I saw on RUclips.

    • @dougmilford7814
      @dougmilford7814  4 года назад +6

      Yeah, it's funny... at first you hate it, and then you love it. I think that's often the case when you're learning something very new and you have to break your assumptions. Well worth it, though!

  • @nonefvnfvnjnjnjevjenjvonej3384
    @nonefvnfvnjnjnjevjenjvonej3384 4 месяца назад

    i have been binging your videos doug and commenting everywhere on your channel.. but seriously thank you so much for these... i wish i could send you a gift or a coffee for all your work... you remind me of two other video teachers I have had in my life: Jeffrey Way and John Lindquist. Some of the best teachers on the planet and noone came close to them so far until now.. You are on the same pedestal for me.

  • @debarghyachakraborty
    @debarghyachakraborty 4 года назад +3

    Learning rust after learning other programming languages absolutely boggles mind 🤯. But in these videos its features have been explained to very basic level, comparing them with other language's features make the videos much easier to learn. Thanks Doug.

  • @TreeLuvBurdpu
    @TreeLuvBurdpu 2 года назад +4

    You can use alt-up-arrow/alt-down-arrow in VS Code to move lines up or down to make your field-sorting even more efficient.

  • @DennisPing
    @DennisPing 3 года назад +2

    I like this style of teaching.

  • @teamunicycle
    @teamunicycle Год назад +1

    I have just discovered your channel with this video, and found it very useful. The content is excellent, but what struck me are two things about the production: no background music - I'm hearing impaired so clarity is extra important to me; and the pacing is great, particularly because you don't edit out pauses, allowing me to follow along without having to continually pause and step back (as much). I look forward to watching more of your videos.

  • @annismonadjem6901
    @annismonadjem6901 4 года назад +13

    Thanks Doug for the excellent training on Rust. When will you have your Generics video ready ? Also, I would love to see more of your fantastic video's in Rust and in particular more intermediary and advanced projects and topics in Rust. Doug is the Best of the Best !

  • @avarise5607
    @avarise5607 3 года назад +1

    I am so happy to be able to have such high quality explanation for free. Thank you, from a new CS student from Poland!

  • @trendingtopicresearch9440
    @trendingtopicresearch9440 Год назад +1

    Pure gold for beginners, thank you so much!

  • @tobuslieven
    @tobuslieven 2 года назад +1

    I think I've heard the ampersand mentioned in relation to dereferencing, coercion, and borrowing. Looking forward to understanding it better. These videos are fantastic. I really appreciate them.

  • @Mephistel
    @Mephistel 4 года назад +4

    23:05 You can derive the Default trait like this as well. When you don't care about what values struct members take so long as they are valid, this can be a faster option. It'll work as long as all the member types have a implementation for Default, which is true for all primitive types and a lot of other standard types. Just adding this since I looked up Default trait in the Docs and others might also be curious.

  • @okarakoo
    @okarakoo 4 года назад +6

    Impressed with the quality of your tutorial, subscribed and can only hope you can keep making more videos!

    • @dougmilford7814
      @dougmilford7814  4 года назад +4

      Oh, thanks! Yeah, I'm working on a new video as we speak and I have whole a ton of topics I want to get to.

  • @AlecHalePletka
    @AlecHalePletka 4 года назад

    Hands-down best Rust series on RUclips

  • @chrisjudge705
    @chrisjudge705 4 года назад +21

    Thank you sooooo much, very good didactics, clear, concise, a warm friendly voice, I love you, as a BRO :-) :-), please more, sugestion if you like, Rust and Vulcan API, 1000 Thanks

    • @dougmilford7814
      @dougmilford7814  4 года назад +7

      I'm glad you like them! I'll take your suggestion into serious consideration. I probably wouldn't be able to get to it for a while because I have a lot of other topics I want to get to first. And, that pesky thing called life keeps getting in the way :) But I'll definitely put it on my list. If more people ask for it, I'll prioritize it.

    • @chrisjudge705
      @chrisjudge705 4 года назад +4

      Thanks, no hurry, oooonly! an idea ;-).
      The reason was, Vulkan (with Vulkano Wrapper for Rust) is OS agnostic, runs everywhere, Rust runs everywhere, Rust tools Visual Studio Code runs everywhere, so for high performance applications on all plattforms I think this is perhaps a good idea.
      So this was ooooonly a little small tiny suggestion ;-)
      Best wishes from Berlin

    • @dougmilford7814
      @dougmilford7814  4 года назад +5

      I agree that it's an important topic. I'm all about cross-platform, hence one of the reasons I love Rust so much. There's a new API standard called WebGPU if you haven't heard of it, and there are some Rust crates actively working on that. I'm super excited! It will be a major leap forward with native/web graphics efficiency, but also cross-platform capabilities. But, it also increases complexities... always a trade-off, right? In any case, I'm salivating for when all platforms can have the same efficient, powerful API implementation.

    • @chrisjudge705
      @chrisjudge705 4 года назад +1

      Thanks for the hint, I have not recognized the difference WebGL and WebGPU

    • @dickheadhex418
      @dickheadhex418 3 года назад +1

      @@chrisjudge705 webgl is the API standard based on opengl ES with some modifications (maybe), implemented by and available in most browsers only. WebGPU is a newer graphics API standard equivalent to opengl or directx and it will be based on vulcan. moreover it wont just be implemented by browsers, but also as SDK extensions for native platforms. So webGPU api will be available as a cross platform vulcan replacemnt(-ish) for native applications also, which you wanted Mr. Milford to cover in his lessons. This is better because the same code will also run in browsers if you switch rust's compile target to wasm

  • @AJ-95
    @AJ-95 2 года назад +2

    I like this guy✌️

  • @Rizal-f2d
    @Rizal-f2d 3 года назад +2

    4:25 Yeah you are right, "Everything is KEREN..."

  • @renetchi
    @renetchi 4 года назад +2

    This is amazing! I love your way of talking. Fun, concise and simple.

  • @wonjunlee5413
    @wonjunlee5413 2 года назад +1

    Best rust tutorial ever

  • @ManasTunga
    @ManasTunga 3 года назад +1

    Your tutorials making a tough language easy to learn

  • @ChumX100
    @ChumX100 2 года назад +2

    Just a small detail: The definition order of fields in structs is not completely irrelevant. If you derive Ord or PartialOrd, the order of the objects will be based on the order of each field, with the fields defined first taking precedence over the ones defined after.

  • @beriu3512
    @beriu3512 2 года назад +2

    Great video, a ton of information perfectly packed without being too overwhelming

  • @Baron-digit
    @Baron-digit 3 года назад +2

    Doug, you rock. I think your videos are super helpful! Definitely deserve more subs!

  • @princepandey9453
    @princepandey9453 3 года назад +1

    rust book is quite good but there are some concepts that I am not able to grasp but bow I can cuz of your tutorials
    ~THANKS!

  • @ka1pana
    @ka1pana 3 года назад +1

    Loving your videos ! Very helpful for absolute beginners with Rust.

  • @cool_sarah
    @cool_sarah 2 года назад +1

    wow thanks for this!

  • @ray-lee
    @ray-lee 3 года назад +1

    best I have seen yet

  • @almudza9803
    @almudza9803 4 года назад +1

    enjoy with your teaching style

  • @kyp0717
    @kyp0717 3 года назад

    Thank you! Thank you! Thank you! Your tutorials are excellent!

  • @puruspace7020
    @puruspace7020 2 года назад

    Thank you Doug, this was very usefull. A friendly, easy to understand tutorial.

  • @greatjobbuddy
    @greatjobbuddy 3 года назад

    Found some great advice in this video managing code.

  • @kartikjavali205
    @kartikjavali205 4 года назад +2

    This is too fast for a person coming from OOPS world, but I'll keep replaying it! really nice stuff!

  • @HarvardNobody
    @HarvardNobody Год назад +1

    Can RUST organize structs internally differently than declared? For example, might it reorganize the above to f64, i32, bool to maximize native alignment? Or does it default to padding out the field bool (followed by three bytes), followed by i32, and f64. For those needing precise positioning of fields I believe the #[repr(C)], #[repr(packed(n))], #[repr(C, align(n))] can be used.

  • @timvw01
    @timvw01 2 года назад +1

    Great videos, very helpful

  • @atlkurtulmus6993
    @atlkurtulmus6993 4 года назад +1

    Great series! I know it was just to show why consistency matters but i was surprised to see you put a double between a boolean and a int32. Does rust have different allignment rules than c++?

  • @royendgel
    @royendgel 3 года назад +1

    The water is warm .. is the 10th time I see this video since 2019

  • @lodoss118
    @lodoss118 3 года назад +1

    Doug you are awesome

  • @yilmazgunalp
    @yilmazgunalp 4 года назад +1

    your Rust videos are so good!

  • @krtirtho
    @krtirtho 3 года назад +2

    As a Web-developer the `loosey goosey JavaScript` thing really hurts😂. Well Typescript mitigates many of those pains👍

  • @jaymartinez311
    @jaymartinez311 3 года назад +1

    I abstract functions and computed properties in swift for ios just like rust in what is called an extension. Also traits are basically protocols in swift. So learning rust is becoming kinda easy but those damn lifetimes are driving me nuts! I have seen you can declare a lifetime wit a '_ vs lets say 'a.

  • @sc5shout
    @sc5shout 3 года назад +1

    Referring to alphabetical order of struct vars. Shouldn’t they be declared from the biggest to the smallest to reduce padding/alignment? Or rust’s compiler is smarter than C++’s in this case?

  • @LaurentLaborde
    @LaurentLaborde 3 года назад +1

    you're a good tutorial person :)

  • @mattetis
    @mattetis 2 года назад +1

    "Structs traits and impl-mentations"
    😅 nice one

  • @samuelemmettbray
    @samuelemmettbray 2 года назад +1

    There will be a DougStruct in all my Rust code; forever.

  • @shadorain
    @shadorain 3 года назад +1

    Totally got a sub from me. This man cracked me up so much! Amazing content too!

  • @aqua3418
    @aqua3418 3 года назад +1

    I believe you can also do Default::default()

  • @preeeby
    @preeeby 4 года назад +3

    Thanks!

  • @yzzyyzzyyzzy
    @yzzyyzzyyzzy 4 года назад +3

    good job

  • @reheyesd8666
    @reheyesd8666 3 года назад +2

    Maybe i will just stick to Python, this is difficult

  • @akhmad84669
    @akhmad84669 7 месяцев назад +1

    4:32 KEREN, hahahahahaha

  • @abdulrachman3313
    @abdulrachman3313 3 года назад +1

    4:23 everything is Keren.

  • @ati43888
    @ati43888 Год назад

    Thanks

  • @poseidonqi
    @poseidonqi 2 года назад

    "Water is warm" 😂😂

  • @jairwen82
    @jairwen82 3 года назад

    😂,angry sound is funny

  • @MrRushifyIt
    @MrRushifyIt 4 года назад +1

    ayyyy

  • @JEBailey
    @JEBailey 4 года назад +1

    The waters warm?

    • @dougmilford7814
      @dougmilford7814  4 года назад +2

      Ha, ha, ha... didn't like that one, huh? Eh, they all can't be winners.

  • @scottb4029
    @scottb4029 Год назад +1

    The waters warm........... Who pee-ed?

  • @Lord2225
    @Lord2225 4 года назад

    This is like C but save.

  • @arturczajkowski4255
    @arturczajkowski4255 4 года назад +2

    16:05, this will lead to a complete mess in large projects...

  • @krellin
    @krellin 3 года назад +1

    composition is great, but it is bad to enforce it and give no other choice... smart programmers know when to use what
    it would be weird to define a Duck as something that has Animal )

  • @-taz-
    @-taz- 4 года назад +1

    IMO, "#[allow(unused_variables)] //This is so I don't get warnings throughout the demo" is slightly more intrusive than yellow squiggles. :)