Rust Programming Tutorial #31 - Hash Maps (HashMap)

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

ความคิดเห็น • 25

  • @superdial8263
    @superdial8263 4 ปีที่แล้ว +6

    I'm so happy this exists. This is the best beginner tut playlist I have found, for Rust. Awesome work dude!

  • @PiyushChauhan2011
    @PiyushChauhan2011 7 ปีที่แล้ว +11

    Good work mate, keep up. I love the short tutorials. Cheers!

    • @dcode-software
      @dcode-software  7 ปีที่แล้ว +2

      Hey Piyush, thank you for the support!
      I was just wondering, what do you mean by short tutorials? Do you mean 2-5 mins, 5-10 mins? Also why is it that you like short tutorials?
      Thanks mate!

    • @PiyushChauhan2011
      @PiyushChauhan2011 7 ปีที่แล้ว +3

      Usually, I like around 5-10 minutes, max 15 minutes, as I usually watch during travelling and then re-watch again to try the code. Also, it doesn't over-whelm me to re-watch again as opposed something which is 30min or 1 hour long.

    • @dcode-software
      @dcode-software  7 ปีที่แล้ว +3

      Yeah that definitely makes sense, thanks for the feedback - I'm just trying to understand the audience right now and what people really want out of these videos, thank you!

  • @cidadesbrasileiras
    @cidadesbrasileiras 4 วันที่ผ่านมา

    That's a great video, thank you. Would you mind to show us how to update a value in the hashmap?

  • @Tvde1
    @Tvde1 5 ปีที่แล้ว +6

    why wasn't .iter() needed here?

    • @Asgar16926
      @Asgar16926 4 ปีที่แล้ว +1

      I'm going to answer this in case other people come here wondering this, I'm sure after 8 months you've moved on from this question.
      At 5:30, dcode uses a for each iterator loop. This is a language concept that uses the iterator of the collection being iterated over, in this case the HashMap, and turns it into what is basically a normal loop. It is a very straightforward way of visiting every element of a collection, including the option to use pattern matching to bind values to variables, as dcode demonstrated in the video above.
      The main difference between this and using marks.iter().foreach(|(subject, mark)| { /*code*/});
      is that the normal for loop is not a closure, with all the pros and cons of that. Practically speaking both these solutions do the same thing in this case.

    • @Tvde1
      @Tvde1 4 ปีที่แล้ว +1

      Asgar16926 Thanks very much for your effort! I hope this helps people with the same question :-)

    • @theeagleseye4989
      @theeagleseye4989 4 ปีที่แล้ว +1

      Bcz, the for loop owns the iterable if it is not used with .iter() method.. If not used .iter(), we wont be able to use the iterable again after that since for loop gains the ownership of the iterable once it is used in loop without .iter(). This concept is called owenership and borrowing in programming field. Some reading on this will let you get a more clear picture

    • @Asgar16926
      @Asgar16926 4 ปีที่แล้ว

      @@theeagleseye4989 Except if we iterate over a reference instead of course, which is where the borrowing part comes in again. Again though, there are situations where you want one or the other.

  • @_akshaydeep
    @_akshaydeep 7 ปีที่แล้ว +2

    subbed, hope to see advanced rust in near future.

    • @dcode-software
      @dcode-software  7 ปีที่แล้ว +1

      Hey thanks for the support - yes I do plan on doing a series on Rust soon and once I get more comfortable with it I'll be creating videos on more advanced concepts.

  • @naufaldbei4234
    @naufaldbei4234 2 ปีที่แล้ว

    where di u get Mark from? isnt marks using s?

  • @element1111
    @element1111 ปีที่แล้ว

    Why the reference to marks on line 25?

  • @cperez08
    @cperez08 2 ปีที่แล้ว

    I like the theme you use, could you tell me how to find it?

  • @БарсикИкрамович
    @БарсикИкрамович 5 ปีที่แล้ว +1

    Seems silly, but what happens to the order of items in HashMap? When you run throw it in a loop, they're coming on screen in a different order every time, if I'm not mistaken

    • @NouifrUIwefdf
      @NouifrUIwefdf ปีที่แล้ว

      HashMap is not ordered, it just linking a certain key with a certain value.

  • @maherkhalil007
    @maherkhalil007 5 ปีที่แล้ว

    Hi dcode, Can you make a video how to manipulate json as variables in rust. what i mean when i do request. how to extract the data from respond and put some keys in variable then can do some calculation?

  • @scottb4029
    @scottb4029 ปีที่แล้ว

    How is a hash map different than a specialized tuple? Is it just the methods you can implement? Thanks for all your hard work. The videos are great.

    • @bladdnun3016
      @bladdnun3016 ปีที่แล้ว

      You probably figured it out by now: A hash map allows you to access elements by key at constant time, whereas a tuple / vector / array would need linear time for that (though access by index is constant time). They also have some beneficial and some detrimental qualities regarding the way the data is actually stored. Hash maps are surprisingly useful, don't sleep on them!

  • @farzin818
    @farzin818 9 หลายเดือนก่อน

    Think i'd kms if i got an A+ in rust programming but failed "professional computing studies". Jokes aside thx for the vid!:D

  • @alihusham1560
    @alihusham1560 2 ปีที่แล้ว

    your name is dom and you are programmer. And one of my professors her name is Nina and she is a nano-scientist what is going on with the world 😂

    • @samdavepollard
      @samdavepollard 2 ปีที่แล้ว

      my uncle is a plumber and he smokes a pipe; like you say, crazy!