Practicing Rust with Rustlings

Transcript

English (Auto-generated)

everyone it is heads Today, we're going to introduce rust. Slings, Wrestling's is just a resource for learning rust and it gives you simple problems that you can solve links to the rust book that help you get the skills you need to solve them. And it's one of the best ways to learn rust because you get all the benefits of the rust book. The rest book is the rust programming language. It's a fantastic book. If you just look up rest book, it'll be the first result on google and wrestling's is based on the rust book. It follows the same trajectory by giving you real code using the principles as you go. So, I had started learning Rust from. Rustling is quite some time ago, I never finished it because I kept going in the book, I got a little impatient. So in order to to tell you all how to be good little rust rust stations, I feel like I should follow my own advice and move a little bit forward in rustling. We're gonna do that this time in other videos, we might implement a simple command line tool, uh, implement a project or whether P I or whatever, but I just want you guys to know about rustling because it really is one of the best resources out there that you're going to find. So right now, I have open primitive types three, I guess this is where I left off. So let's see what's going on as you see, each part will be broken. It will give you a bunch of broken programs and you have to use your newfound rust skills to fix them. So we have to create an array with at least 100 elements in it. Where the, where the question mark, question mark is okay. And it's pretty easy to create an array. All you have to do is say, you know, you can say, you know, 1123. Right? Mm hmm. And we can just keep doing that up to 100. That would be pretty repetitive. Right? So it says, may I have raised like that for bricks? We got the Aragon. So the code isn't broken anymore. But we didn't do the thing actually said to do, which was create this 100 element array. So how are we gonna do that? You might know about vectors. You learn about those earlier in wrestling's if you don't know about them, you know, install wrestling's and start from the beginning, I'm just trying to give you guys an idea of how wrestling's work. So if this is a little bit beyond where you're at in rust. Don't worry. Oh, but yeah, let's let's see how would we do that? We could create 100 elements. We can't dynamically add to it like a vector because in rust arrays cannot be changed. You get the array you get And that's just how it is. So mm hmm. Pretty interesting. Huh? Yeah. Well, let's try some ideas. one thing we could do is declare this to have the type of an array of, let's say in this case we have numbers. Right? So also everything in the rain has to have the same type. So you have the type and how many elements there are? Let's see if we can do this. Let's see what we can say. We're gonna give it five elements and yeah, I definitely didn't like that. Okay. We said, yeah, we have these five elements and it's like new. Okay, well, let's just see if we can declare a as being this kind of array. Okay. It's mad because we're trying to get the length of the value that we haven't actually initialized. Hmm. Okay. So what do we do when that happens if you notice up here? It has the option to give us a hint. Let's look at a hint. Uh says there's a shorthand to initialize arrays with a certain size. This does not require you to type 100 items, but you certainly could. For example, you can do let array equals something times 10. Okay, well, I did not know that. So I learned something they're beautiful. So we'll go back into watch mode, wrestling's watch and say let our array equal. Will have it equal. Alright, completely forgot what its impact towards. Okay. So we use a semicolon because we can't use a comma because that would just that would make you think it's just another thing in the array, right? So I'll just have it equal the number zero 100 times and it works. We solved it. So there you go, that's how wrestling works. Um Don't worry again, if this is a bunch of new concepts to you, I mean I'm in the middle of rustling because I abandoned it months ago, but I'm gonna continue down in my own time for the rest of the tutorial. We're gonna focus on just learning rust in a logical progression. But for those rust learners out there, I highly recommend wrestling's as you can see, it's not particularly challenging. It just focus on syntax. I mean, if you don't know this feature it's challenging, right? But it always gives you what you need beforehand and if not it has these hints, so it's pretty cool. Um I hope that was helpful for you all and I'm looking forward to diving deeper into rusts basics, fundamental syntax and starting from there. Thank you all for your time and have fun doing some wrestling's
14 Views 0 Likes 0 Comments

Rustlings: https://github.com/rust-lang/rustlin

Comment
Leave a comment (supports markdown format)