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.
@@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?
@@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.
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...
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!"), }
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."), }
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.
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
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.
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
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?
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.
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
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.
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 :-)
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.
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/
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?
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?
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.
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
Similarly at 07:55, I type the code as follows: fn main() { let mut v = vec![1, 2, 3, 4, 5]; let first= &v[0]; v.push(6); } But I didn't get any error, instead just a warning: warning: unused variable: `first` --> src/main.rs:3:9 | 3 | let first = &v[0]; | ^^^^^ help: if this is intentional, prefix it with an underscore: `_first` | = note: `#[warn(unused_variables)]` on by default Can anyone explain why the borrowing rule does not work here? Thanks!
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 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!! 😭
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?
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)
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.
📝 Get your *FREE Rust cheat sheet* : www.letsgetrusty.com/cheatsheet
Use it often!
nice to see team blue and yellow :)
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.
नमस्ते brother you're the best. Thanks for saving me from go🌚🤝🏼
From what others told me, Go is really only good for back end services, not games or GUIs. Is that right?
@@Christobanistan Mostly go is used for backend etc, yes
@@afraid2letgo Doesn't answer my question.
@@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?
@@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.
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...
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!"),
}
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."),
}
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
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.
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
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.
Should probably mention collect. It's one of Rust's best ergonomic features.
lool you and wallace gotta be having fun. glad you chose the right side
Hello
These series are the best rust tutorial I have ever found on youtube
Thank you so much
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
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?
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.
true, rust book is the only programming language I've learnt reading books and watching videos, and it's so exciting
the section on string just saved me from hours of frustrations (after I already have hours of frustrations lol)
great work cool work, for those who are uncomfortable reading books or just don't like reading books.
men, you explanations are really really good, thanks for that. 🥰
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
I feel like I ran a marathon after watching each of these videos
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.
By the way, thanks a lot for wonderful videos.
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 :-)
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.
To copy a simple integer, you just remove the &. I assume we will learn about copying more complex types later.
this was amazing, thank you :)
Thanks for those amazing videos talking about rust!
Thanks! What Linux distribution are you using? Fonts look very MacOS-esque.
Hello, How would you represent a double linked list in Rust? I've heard that graphs are difficult to represent in rust due ownership
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/
"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?
it does make sense if you think about the amount of libs/projects that do not need to do this.
@@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.
this channel is awesome! Incredible level ! congrats
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?
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?
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,,
Great content! What extensions do you use?
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.
Trying to understand HashMap::entry. That function returns an owned Entry
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
the video on strings, mentioned about 18 mins into this one: ua-cam.com/video/Mcuqzx3rBWc/v-deo.html
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
Similarly at 07:55, I type the code as follows:
fn main() {
let mut v = vec![1, 2, 3, 4, 5];
let first= &v[0];
v.push(6);
}
But I didn't get any error, instead just a warning:
warning: unused variable: `first`
--> src/main.rs:3:9
|
3 | let first = &v[0];
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_first`
|
= note: `#[warn(unused_variables)]` on by default
Can anyone explain why the borrowing rule does not work here? Thanks!
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?
The "language server" is what gives me those type annotations (shadow text). Simply install the *rust-analyzer* VS code plugin.
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.
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?
🙏 नमस्ते 🙏 Love your videos! ❤
thank you for your efforts
А я то думаю почему мне так легко понимать ваши уроки))
Спасибо
damn I started laughing when you said नमस्ते (namaste)
Did I butcher it? 😅 At least my Russian pronunciation is on point 😎
@@letsgetrusty it's fine it's not your mother tongue so can't help
@@letsgetrusty Kudos for explaining UTC encoding and unicode. Especially Grapheme clusters. दन्यवादः (Thank you)
@@HrishikeshMuruk It's UTF.
Its missing a video covering streams, to hande large amounts of data on demand.
Your videos are extremely helpful. I wish you had the channel membership option turned on or, maybe, a Patreon page.
I do this out of the kindness of my heart :)
@@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!! 😭
line number 4 at 9:00, throws error
What is the error?
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?
not really, he mentioned vectors are stored on heap so they get dropped when they get out of scope
Amazing video
I want a guide on making a Solana smart contract. lol
Well Explained
What extension are you using that shows the types when not explicitly stated?
Found it! (it's at the bottom of the application: rust-analyzer)
Very clear video, shame about the background music. Very distracting.
you're the best
omg, this topic very very difficult for me
Guys rust kinda difficult. Just keep swimming. I really decided to jump from python to rust, so be worth it though!
Every time I encounter some difficult concepts I say is this language really worth
8:00
Why use vectors ? array looks easier to use for same use cases !?
arrays unlike vectors are of a fixed size
@@nofacee94 thanks ! I was don't understand we can't push new data in array in Rust :/
@@nofacee94 Not only are arrays of a fixed size, but that size must also be known at compile time.
your flag is facing the wrong way
Real programmers need no generics
Go doesn't have generics? Sounds like an unfinished language.
Real world projects need no garbage collection spikes
@@letsgetrusty it will soon! (Go2) :)
@@GolangCafe Go2Rust?
@@GolangCafe
more like Go use a decent language
300th view
Із кожним новим відео розумію наскільки Голанг сакс
Здравствуйте!
Здраствуйте!
Use hashbrown, it's faster then HashMap
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)
@@Gramini yeah for fast non-secure hash maps there's AHashMap from ahash, faster then default impl
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.
Awesome Content
Здравствуйте!
नमस्ते