Rust Programming Exercises: Double Linked List

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

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

  • @vintagewander
    @vintagewander 2 ปีที่แล้ว +4

    Thank you so much for this video, it helped me learned a lot more about Rust than I have ever expected
    But I got to say programming a linked list in Rust in this safe version is way harder than other programming languages that I've used, C++ for example is so quick and easy, but I'm going all in for the safetyness Rust provides

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

    Thanks very much for this one. In the process of implementing a LRU cache and wasn't 100% on double linked lists in Rust... SAVE!!

  • @ostadomid3355
    @ostadomid3355 2 ปีที่แล้ว +4

    Thank you. Demystifying such topics are really needed.

  • @Stumashedpotatoes
    @Stumashedpotatoes 2 ปีที่แล้ว +6

    I only wish you explained *WHY* you used RefCell and Rc, how you knew you needed them, etc.

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

      year later and I'm coming back to rust and this video. do you have a video that would explain that to me?

    • @flippert0
      @flippert0 11 หลายเดือนก่อน +2

      I think YTer "Let's get rusty" has a good explanation for it in his vid about circular references. The problem with doubly-linked list is that we have structures mutually referencing each other, which have to modify each other. Can't use ownership here, but
      "&" or "&mut " woudn't work either since there's only one modifying reference allowed. That's too complicated for the borrow-checker and so we have to revert to thos awkward "smart pointers".
      Disclaimer: I'm still a Rust novice, so surely somewhat has a better explanation?

  • @SaifAli96
    @SaifAli96 2 ปีที่แล้ว +3

    Hi Thomas, do you have a video where you show us how you setup your IDE for Rust? Please a tutorial for VIM + Rust.

    • @SaifAli96
      @SaifAli96 2 ปีที่แล้ว +1

      @@nyxtom thank YOU so much! ❤️

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

      @@nyxtom Do you by any chance have dotfiles repo to have a look at? Thanks.

  • @DreadDeimos
    @DreadDeimos 2 ปีที่แล้ว +4

    Comment for the algorithm god!

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

      @@nyxtom I just don't have to say anything of value that I haven't mentioned before :D

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

    I don't think there is any null pointer optimization for Rc or Weak. It lists right there in the documentation you pointed to what types have NPO and neither are listed.

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

      There is.
      println!("{}", core::mem::size_of::()); // 24 (not optimized)
      println!("{}", core::mem::size_of::()); // 8
      println!("{}", core::mem::size_of::()); // 8
      println!("{}", core::mem::size_of::()); // 8
      Anything that contains a raw pointer or reference within it is usually optimized
      println!("{}", core::mem::size_of::()); // 24
      println!("{}", core::mem::size_of::()); // 24
      println!("{}", core::mem::size_of::()); // 24
      println!("{}", core::mem::size_of::()); // 24

  • @GlobalYoung7
    @GlobalYoung7 2 ปีที่แล้ว +1

    Thank you 😊

  • @yaminnather521
    @yaminnather521 6 หลายเดือนก่อน

    Bro what theme are you using?

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

    Is there no way to create a helper push_helper(self, value, a, b) and then push_front(self, value) calls push_helper(self, value, head, tail) and push_back(self, value) calls push_helper(self, value, tail, head)?