📝 Get your *FREE Rust cheat sheet* : www.letsgetrusty.com/cheatsheet
@keatonhatch62133 жыл бұрын
This is by far the best coding tutorial I’ve ever seen. The explanation of every step, the why of every step and the refactoring steps. Keep it up I’ll be subscribing
@johnterpack3940 Жыл бұрын
This was a perfect tutorial. Seriously, this is how you do it. I know zero Rust. But I mostly understood the original code well enough based on knowing things like Powershell and Bash. Then, even though I didn't understand much of the tweaks you made, I understood why you were making them and I have no doubt that reading the book would clarify what you did. But the real key to what makes this a phenomenal tutorial is that it is simple enough to be accessible to newcomers while still being something useful. I could easily see myself using this tool as part of a larger program I want to build. All I'd need to add is whatever it takes to decompress/decode the files I need to read and then a bit of code to manipulate those files and their contents. Libraries exist to handle the former, I just have to find them and port them to Rust. The latter is probably fairly trivial. Bottom line is that you showed me a beginner project that actually leads to something. And that is how you motivate people to learn.
@martinmecir25483 жыл бұрын
You Bogdan, are a legend! Thank you very much for this, we need more tutorials like this. The refactoring steps are priceless, learned a lot Also will you make a tutorial on futures? Would love to see comparison of Rust futures with JS/TS promises!
@letsgetrusty3 жыл бұрын
Just put that on the todo list. Thanks for the feedback!
@thingsiplay3 жыл бұрын
Very good tutorial. Also I appreciate how the video was edited for not wasting my time. Just the tip of the iceberg.
@mabroorahmad21823 жыл бұрын
This is the most amazing tutorial ever. Many can write code but only few can write good code and you are morphing us into those few.
@thanhdatvo0 Жыл бұрын
The syntax is so elegant. Thank you for the explanation!
@delkott Жыл бұрын
Thanks a lot for this very informative collection of tutorials, Bogdan! I am learning Rust [coming from C++] from your series; your explanations, and example collections are better than anything else I have seen online, including paid courses. If I may make a suggestion - it would be fantastic if you prepared a tutorial on developing a Rust desktop application with UI and database, say, using Tauri. Thanks again, and keep up the excellent work!
@singhsaubhik3 жыл бұрын
I really loved your content, appreciate that. Please always keep going with Rust. Thanks
@markmcdonnell3 жыл бұрын
Super useful breakdown of how to work through a problem in rust. The refactoring was of particular interest.
@exoticcoder53653 жыл бұрын
Very Useful and Easy to follow step by step
@procyonq2 жыл бұрын
So nice tutorial to build a basic CLI app! Thank you so much!
@raupeniemalssatt81932 жыл бұрын
@ 14:00 I would use eprintln!() instead of println! to really print an error signal insted of a normal printout.
@grvxs92303 жыл бұрын
Love the content.
@_jdfx2 жыл бұрын
Great tutorial, thanks Bogdan!
@jds23282 жыл бұрын
Appropriate to your patience *SO MUCH*
@GolangDojo3 жыл бұрын
I wouldn’t mind wine and banters at this new place
@nathanielwoodbury26923 жыл бұрын
Wow Thankyou so much for this
@alvaroandresherradacoronel89728 ай бұрын
Hi Bogdan, At the beginning of the refactoring section you have this line of code formatted like this: let contents = fs::read_to_string(filename) .expect("Something went wrong reading the file"); I'm following the video on VSCode using the extensions you recommend on your channel, and it forces the format to this: let contents = fs::read_to_string(filename).expect("Something went wrong reading the file"); I wanted to know what your settings are on RustAnalyzer and VScode or if you know how to change that setting. I appreciate your help (or the help of anyone who happens to read the comment).
@RodrigoStuchi2 жыл бұрын
Absolutely amazing content you sir are producing. I'm your channel. Thank you
@sathishkannan660010 ай бұрын
I think you can return Result type from the main and it will automatically exit if an error occurs, but you need specifiy the error.
@tashima423 жыл бұрын
This is the type of video that te community needs
@inx18193 жыл бұрын
When will there be a video on the Box? Sounds useful but I can't wrap my head around it hah
@inx18193 жыл бұрын
If I understand correctly, dyn Error is simply any type that implements the Error trait. However, it could be any type - a struct with 1 field or 100, the compiler doesn't know the size, so it can't be returned from a function like that. To fix that, we put it on the heap inside of a Box, basically a pointer, along with the info on the size of the data inside. The compiler knows the size of Box because it's essentially just a pointer.
@letsgetrusty3 жыл бұрын
Sounds like you figured it out. Your explanation makes sense to me although I haven't dug into it yet.
@radiknazmiev3 жыл бұрын
@@inx1819 Why not just Box? What is the dyn keyword for?
@jacobhinchliffe66593 жыл бұрын
@@radiknazmiev dyn means we get the type at run time I believe?
@CYBERNETIC-ANGEL8 ай бұрын
what does the "{:?}" mean in the first println! argument?
@sahilverma40773 жыл бұрын
the new setup looks better
@pynchia41192 жыл бұрын
@3.07 why do you use a reference to each arg in the newly created collection? Why not assign it as a String? Also: the arg strings are stored somewhere already, why do we need a collection if we use references later? Can't we just refer to the original strings, e.g. let query = args.next().expect("error");
@ak_clirustacean62412 жыл бұрын
Thanks for saving our time! I have a little question, when we created parse_config function we are expecting reference to an array of strings as an argument, but what we're passing is vector of strings. I see it works but could you please elaborate it a little bit more? What's the rule behind it that makes a compiler nice to us all of a sudden :) ?
@nofacee942 жыл бұрын
That is not an array of strings as an argument, it is a reference to a slice of the vector.
@mikutut2 жыл бұрын
What do we pass as an argument is not an array of strings, but in fact a slice of the vector. We didn't specify an index or a range, which means we are passing a slice of the whole vector.
@asdqwe44272 жыл бұрын
Hmm, having a new function return a result feels like a bit of a smell to me. Is this a common way to handle things in rust? To me a constructor should always work, and for that reason I would much prefer to check all the errors before calling it. If I'm getting the arguments for a constructor from a vector or an arrray, I would probably do the validation beforehand and in this simple case I probably wouldnt create a constructor at all for this struct. But perhaps I am wrong and there is a good reason to do this?
@knowledgedose1956 Жыл бұрын
Hi, Bogdan. Can you advise any Vscode plug-ins for rust. I love how you get types autocompleted in your setup
@xDanishGamerz3 жыл бұрын
at 10:22 you use config.filename twice in your parameters. When i try to do that it says I can't because I move values, so fix it used & to reference it in the paramters. Why is it you didnt need to do reference the values but I do?
@lee452833 жыл бұрын
What rust language analyser are you using in VS code?
@inx18193 жыл бұрын
there are two main extensions: the "official" one and "rust-analyser". The second one has more features and gets updated more.
@ati43888 Жыл бұрын
Thanks
@umut82442 жыл бұрын
The original rust Lang Book is not so good in this chapter. But you are good.
@ClearerThanMud3 жыл бұрын
Good work as usual. Just a note for viewers: in truth you wouldn't want to use read_to_string() for an arbitrary file -- it's better to iterate over strings read one by one from the file. read_to_string() is great for config files and the like that you know are going to be small and you need the whole thing at once. I'd like to see Bogdan (sp?) do another CLI video in which he uses structopt and handles errors via the anyhow crate (or something similar), with main() returning a Result. Rust has good support for CLIs, so we really should use it. Bonus points if you show viewers how to process multiple files simultaneously.
@jacobhinchliffe66593 жыл бұрын
He is just following along with the Book, but I'd like to see to see somebody making a video on that
@DuyTran-ss4lu2 жыл бұрын
Awesome
@dzibanart85213 жыл бұрын
Question, Couldn't have you used '?' operator Instead of .unwrap_or_else() ? If not, why?
@inx18193 жыл бұрын
Where? Inside the main function when checking the result of the Config::new function? You can but it doesn't make sense here because it defeats the point - we wanna handle it ourselves, to print a nice error message. Also you'd need to change the main function to return a Result - and frankly I hate doing that on the main().
@FrayedString2 жыл бұрын
FWIW following this video on Jan 18, 2022, I had to change the process::exit(1); to process::exit(0); to avoid an additional error message saying the process didn't exit successfully. Running on Windows. stable-x86_64-pc-windows-msvc unchanged - rustc 1.58.0 (02072b482 2022-01-11)
@miguelguerrero33942 жыл бұрын
Same problem, thank you
@PatrickIsbendjian2 жыл бұрын
Basically, if you exit because of an error you shouldn't use exit(0) which means your program executed successfully. It doesn't matter much in this particular case, but if you were to chain your program with others inside a shell script or on a command line, it would cause the script or chain to miss the failure, which may be problematic.
@do0nv2 жыл бұрын
That's cargo outputting the error. The .exe file doesnt show the "process didn't exit successfully" message.
@caveofmovies85973 жыл бұрын
👍
@pynchia41192 жыл бұрын
@2.01 you say ".collect needs to know what type of collection we want". WHAT? How does it get the type you specify to the variable you are creating? I understand the Vec type handles generics, and that's what you specify the args variable should hold. But what has it got to do with .collect? I think your statement is very misleading
@arttartkhai Жыл бұрын
I'm nobody! Who are you? Are you nobody, too? Then there's a pair of us - don't tell! They'd banish us, you know. How dreary to be somebody! How public, like a frog To tell your name the livelong dreary To an admiring bog!