Это видео недоступно.
Сожалеем об этом.

Common Collections in Rust

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

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

  • @letsgetrusty
    @letsgetrusty  3 года назад +13

    📝 Get your *FREE Rust cheat sheet* : www.letsgetrusty.com/cheatsheet

  • @gautamprikshit1
    @gautamprikshit1 2 года назад +67

    नमस्ते brother you're the best. Thanks for saving me from go🌚🤝🏼

    • @Christobanistan
      @Christobanistan 3 месяца назад

      From what others told me, Go is really only good for back end services, not games or GUIs. Is that right?

    • @afraid2letgo
      @afraid2letgo Месяц назад

      ​@@Christobanistan Mostly go is used for backend etc, yes

    • @Christobanistan
      @Christobanistan Месяц назад

      @@afraid2letgo Doesn't answer my question.

    • @afraid2letgo
      @afraid2letgo Месяц назад

      @@Christobanistan Go is mostly used for backend -> Go is good for backend. Go is mostly used for backend -> Go is barely used for GUIs/games, if ever -> Go isn't really good for GUIs/games. What part of your question did I miss?

    • @Christobanistan
      @Christobanistan Месяц назад

      @@afraid2letgo Sorry, I thought I had explicitly asked. What exactly is it about Go that makes it unsuitable for GUIs? I understand the nondeterminism of the GC is why games aren't a good idea, but no one seems to know why it's unsuitable for GUIs.

  • @daque1960
    @daque1960 3 года назад +37

    I am finally using vectors and hashsets. I didn't have to store a key/value and the fact it doesn't allow duplicate entries was perfect. I still make tons of mistakes but these videos help a lot. If you're learning making a lot of mistakes and fixing them is a good way to learn.

  • @2002budokan
    @2002budokan 2 года назад +16

    Rusty content suggestion:
    How about a playlist that involve each type in Rust collections library, that tells their traits, implementations etc? Or series of playlists that covers the whole Rust standart library? Rust is a big ocean that can feed Rusty channels. There are very interesting crates too, for example wgpu...

  • @yapayzeka
    @yapayzeka 2 года назад +18

    at 10:10 I made matchmaking with inspiration from previous lessons:
    match row.get(0) {
    Some(data) => match data {
    SpreadsheetCell::Int(i) => println!("{} is an integer type data.", i),
    _ => println!("Cell has not an integer type data."),
    },
    None => println!("Cell not exists!"),
    }

    • @creeper283
      @creeper283 2 года назад +9

      Could even use a nested destructuring instead of nesting match expressions:
      match row.get(0) {
      Some(SpreadsheetCell::Int(i)) => println!("{} is an integer type datum.", i),
      Some(_) => println!("Cell has a non-integer type datum"),
      None => println!("Cell does not exist."),
      }

  • @firstname1817
    @firstname1817 Год назад +2

    Thanks for the explanation at 13:56. While reading this chapter I was trying to wrap my mind around why it's written like that

  • @sunnymittal1906
    @sunnymittal1906 Год назад +5

    In case anyone's interested, in newer versions of Rust (and perhaps even the one Bogdan is using), you don't actually need to specify a type when initializing an empty vector, even though "rust doesn't know what the type will be." It's probably good practice but the compiler will infer the type after the first usage:
    ```
    let mut v = Vec::new();
    v.push(1);
    ```
    This compiles just fine because the first time rust sees something going into `v`, it sets the type accordingly, in this case to i32.

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

      He said something along the lines of like "Because we're not adding anything of a particular type, we have to specify the type" so I don't think the video is outdated or anything

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

    Thanks for the video. For a newbie like me, this is a pretty confusing example (7:55). After playing around with the code I was able to understand the proper solution. We're not able to assign variable `third` a reference to the third value, but it's totally working to assign it the value. So if you need to mutate the vector but before the mutation you want to store the `third`, just do it by value. That totally makes sense.

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

    the section on string just saved me from hours of frustrations (after I already have hours of frustrations lol)

  • @sephirothu1290
    @sephirothu1290 8 месяцев назад +1

    Hello
    These series are the best rust tutorial I have ever found on youtube
    Thank you so much

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

    lool you and wallace gotta be having fun. glad you chose the right side

  • @scheimong
    @scheimong 2 года назад +7

    Should probably mention collect. It's one of Rust's best ergonomic features.

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

    i am using this series as revision or summery and that is best for me after reading the book for any chapter or before reading i am learing kind of many new things from this

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

    I wouldn't normally watch a tutorial like this for another language. I would actually go through the rust book that you are presenting.
    The problem with that is I can't help myself from scrolling right through to the first code example, and if I think I can understand it, I paste it in my own code or adapt it to what I want to do. I know enough different languages that this usually works well.
    But with the whole ownership stuff and the result types, and the "if let Ok(new_variable) = some_func()", I wasn't able to understand it just from looking at the syntax. Well ... I did sorta figure out what the "if let Ok(new_var) = some_func()" was doing, but seeing as I had skipped learning about Enums (which are quite different from what I expected), I can't say that I understood it for real.
    Until I watched you videos which forced me to go through everything slowly.

    • @jeffreyefemena1082
      @jeffreyefemena1082 5 месяцев назад

      true, rust book is the only programming language I've learnt reading books and watching videos, and it's so exciting

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

    men, you explanations are really really good, thanks for that. 🥰

  • @a_maxed_out_handle_of_30_chars
    @a_maxed_out_handle_of_30_chars 9 месяцев назад +1

    this was amazing, thank you :)

  • @pythona291
    @pythona291 10 месяцев назад

    great work cool work, for those who are uncomfortable reading books or just don't like reading books.

  • @lawalbabatundeutility4230
    @lawalbabatundeutility4230 Год назад +2

    Thanks for this amazing content Bodgan! I am almost done with the rust book and I can testify that this series helps cement the little I have known so far. I hava question please: how did you set up rust-analyzer to do type annotation automatically?

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

    Thanks for those amazing videos talking about rust!

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

    I've been wanting to create a programming from scratch video series, and touch on encodings, how assembly gets run by a bare metal computer with the CPU, registers etc. and how that is the stack and heap and how it works. I've also wanted to learn Rust. This isn't the first video of your series I've watched but man, I love how you explain things. It's paced so nicely, really a pleasure. You are getting my motivation back to start on that series of videos

  • @sureshnimbalkar1929
    @sureshnimbalkar1929 Месяц назад

    At video location 10.17, Bogdan says in a match statement, an underscore (_) covers all other options in an enum. In my view, this is only partially correct. In the underscore option, we are ignoring the values from the enum. If we use 'other' instead (of underscore), we can use the respective values.

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

    At 7:50 I was hoping you'd explain how we could solve the problem of wanting to print out the third element value after pushing onto it. Maybe it's obvious, but you built up the problem without the solution :-)

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

      You either need to copy the value in the first place, or you need to swap line 4 and 5. This is also what you need to do in C++ to avoid risking a segfault. The difference is that rust gives a compilation error, C++ compiles and hopes for the best.

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

      To copy a simple integer, you just remove the &. I assume we will learn about copying more complex types later.

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

    this channel is awesome! Incredible level ! congrats

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

    I feel like I ran a marathon after watching each of these videos

  • @rtdietrich
    @rtdietrich 7 месяцев назад

    Complex? I had to laugh at the end at how easy it was. I thought oh dear what's coming....and then some baby stuff

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

    hey Bogdan, thank you for your videos, it's great Rust resource. Considering you are from Ukraine (My guess, you mentioned it before?) fingers crossed everything will be fine in next coming weeks & months

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

    Hello, How would you represent a double linked list in Rust? I've heard that graphs are difficult to represent in rust due ownership

    • @letsgetrusty
      @letsgetrusty  2 года назад +8

      Yes linked lists and graphs are difficult in Rust and not something you should dig into when first learning the language. There is a book dedicated to implementing linked lists: rust-unofficial.github.io/too-many-lists/

  • @adamhenriksson6007
    @adamhenriksson6007 3 года назад +15

    "In order to keep the rust standard library lean, the ability to iterate over grapheme clusters is not included by default. "
    ... they did what now?

    • @fenilli
      @fenilli 2 года назад +6

      it does make sense if you think about the amount of libs/projects that do not need to do this.

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

      ​@@fenilli Agreed. Unicode is a massive subject. I'm all for putting such things in a library. Especially in a lower-level language like rust.

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

    thank you for your efforts

  • @prasanthkarunakaran5883
    @prasanthkarunakaran5883 3 месяца назад

    I think at 7:26 in the video, say will throw error.
    fn main() {
    let mut v = vec![1, 2, 3, 4, 5, 6,];
    let third = &v[3];
    v.push(7);
    match v.get(2) {
    Some(third) => println!("The third elemet is {}in vector {:?}", third, v),
    None => println!("there is no thrid element.")
    }
    }
    But I tried it in rust 1.78. The code working fine. Is they updated it?

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

    damn I started laughing when you said नमस्ते (namaste)

    • @letsgetrusty
      @letsgetrusty  3 года назад +6

      Did I butcher it? 😅 At least my Russian pronunciation is on point 😎

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

      @@letsgetrusty it's fine it's not your mother tongue so can't help

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

      @@letsgetrusty Kudos for explaining UTC encoding and unicode. Especially Grapheme clusters. दन्यवादः (Thank you)

    • @31redorange08
      @31redorange08 3 года назад +1

      @@HrishikeshMuruk It's UTF.

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

    Your videos are extremely helpful. I wish you had the channel membership option turned on or, maybe, a Patreon page.

    • @letsgetrusty
      @letsgetrusty  2 года назад +10

      I do this out of the kindness of my heart :)

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

      @@letsgetrusty Wow, don't know what to say now. Just want to send you tons of appreciation and love ❤️ Honestly if C++ has tutorials like yours, it would save me, a beginner, huge amount of time!! 😭

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

    Amazing video

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

    Well Explained

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

    you're the best

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

    Great content! What extensions do you use?

  • @TeppopucT
    @TeppopucT 10 месяцев назад

    А я то думаю почему мне так легко понимать ваши уроки))
    Спасибо

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

    Trying to understand HashMap::entry. That function returns an owned Entry

  • @Keolamation
    @Keolamation 3 месяца назад

    I want a guide on making a Solana smart contract. lol

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

    When you print the last map, I'm wondering why it prints items is random order? I would expect first word will be always first there but it's not the case. Is there some hidden parallelism inside or what?

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

    Thanks! What Linux distribution are you using? Fonts look very MacOS-esque.

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

    Namaste from india

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

    Could you do a video about setting up VS code to get prompts and shadow fills like you do. For example, when I type let s1 = String::from("Hello"); I do not get the ":String" in light font like you do. Also, you mentioned in one of your videos that you are running a "language" server. How does that help? Could show how to install that feature?

    • @letsgetrusty
      @letsgetrusty  3 года назад +7

      The "language server" is what gives me those type annotations (shadow text). Simply install the *rust-analyzer* VS code plugin.

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

    I am confused. What is a reference in Rust? It is more like a pointer or like a reference? looks like I can access object's fields like a reference but to assign a value to referenced field I need to dereference it like a pointer.

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

    I would like to see how I can use rust to pull a CSV file from SFTP (SCP) then parse it and iterate through it.

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

    Do you have the code from these example in Github?
    it will be easier to clone the repo and run them to follow the videos, than typing them,,

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

    omg, this topic very very difficult for me

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

    line number 4 at 9:00, throws error

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

    the video on strings, mentioned about 18 mins into this one: ruclips.net/video/Mcuqzx3rBWc/видео.html

  • @chrs-wltrs
    @chrs-wltrs 2 года назад

    What are the use cases where you would want to access the bytes or characters of a UTF-8 string as opposed to the graphemes?

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

    Guys rust kinda difficult. Just keep swimming. I really decided to jump from python to rust, so be worth it though!

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

      Every time I encounter some difficult concepts I say is this language really worth

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

    8:00

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

    Its missing a video covering streams, to hande large amounts of data on demand.

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

    I must be missing something. From what you said it sounds like once you add something to a vector you can't use it anymore because it's out of scope. If that's the case, what use is a vector?

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

      not really, he mentioned vectors are stored on heap so they get dropped when they get out of scope

  • @hcoderhy768
    @hcoderhy768 5 месяцев назад +1

    Здравствуйте!

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

    What extension are you using that shows the types when not explicitly stated?

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

      Found it! (it's at the bottom of the application: rust-analyzer)

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

    Why use vectors ? array looks easier to use for same use cases !?

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

      arrays unlike vectors are of a fixed size

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

      @@nofacee94 thanks ! I was don't understand we can't push new data in array in Rust :/

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

      @@nofacee94 Not only are arrays of a fixed size, but that size must also be known at compile time.

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

    300th view

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

    Real programmers need no generics

    • @letsgetrusty
      @letsgetrusty  3 года назад +15

      Go doesn't have generics? Sounds like an unfinished language.

    • @hchydra3666
      @hchydra3666 3 года назад +15

      Real world projects need no garbage collection spikes

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

      @@letsgetrusty it will soon! (Go2) :)

    • @sleepymarauder4178
      @sleepymarauder4178 3 года назад +6

      @@GolangCafe Go2Rust?

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

      @@GolangCafe
      more like Go use a decent language

  • @user-nz6gy6tg5f
    @user-nz6gy6tg5f 2 года назад +1

    Здраствуйте!

  • @marktime.
    @marktime. Год назад

    your flag is facing the wrong way

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

    Із кожним новим відео розумію наскільки Голанг сакс

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

    Use hashbrown, it's faster then HashMap

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

      Good call. But you no longer need it today, as it's now the standard.
      "Since Rust 1.36, this is now the HashMap implementation for the Rust standard library."
      (from their GitHub)

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

      @@Gramini yeah for fast non-secure hash maps there's AHashMap from ahash, faster then default impl

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

    The compiler panics here:
    let mut v4 = vec![1, 2, 3, 4, 5];
    let third = &v4[2];
    v4.push(55);
    println!("The third element is: {}", third);
    But it's everything ok here:
    let mut v4 = vec![1, 2, 3, 4, 5];
    let third = &v4[2];
    println!("The third element is: {}", third);
    v4.push(55);
    And the question is WHY? I' m not changing the fucking third element no matter what nor the base address of the fucking vector that the third variable was binded to. The is no point for this stupid restriction.

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

    Здравствуйте!