Greetings to the Rust community! I am a newcomer to the Rust programming language, although I possess experience in other object-oriented programming languages. It has come to my attention that Rust is known for its intricacies in comparison to many other programming languages. I have initiated my journey by reviewing tutorials and delving into the initial chapter of the Rust Book.
As a novice, I am in search of guidance on expediting my grasp of Rust to the point where I can proficiently write code. I kindly request your assistance in directing me to valuable learning resources that tackle the more challenging aspects of Rust. Furthermore, if anyone could provide a compilation of utility functions commonly employed in Rust, it would be greatly appreciated. Thank you for your support.
In Rust we have the benefit of an easy-to-use and ubiquitous package manager and registry (https://crates.io/), so we share useful code by publishing it in libraries. For example, the
itertools library is often useful and consists of a lot of relatively small functions.
As you learn Rust and read existing code, you will learn about many of these libraries. To get started, blessed.rs is a web site that attempts to be a list of notable and recommended libraries. But the ones which are actually of interest to you will depend greatly on the kinds of programs you wish to write.
Additionally, the Rust standard library, while intentionally minimal, still likely contains more “utility” functions than you might think. Once you are far enough along to understand it, I highly recommend perusing the standard library documentation — start at the top and skim through each module's documentation. There's a lot of useful information about what you can do.
With all of these resources, there is rarely a need for passing around collections of snippets.
Hello fellow traveler at the beginning of the road
Knowing other languages helps, a lot, I think. But it also can be difficult to make your mind accept differences that look the same. False friends, I think you could call them.
What helps me is a combination of:
practice, again and again and again, until I really understand a concept, and only then moving to the next. The compiler is great in explaining what you do wrong.
Vim + the rust plugin + YouCompleteMe-plugin
Bacon, a tool that lets you see compiler warnings and errors on another screen while you are writing
YouTube (yes, really, if you are not behind your coding machine, youtube has a lot to offer in backgrounds, examples, and so on, to inspire and to explain)
If I may, a piece of advice: don't fall into the trap of over-mystifying the language. Rust is not weird; most of the design decisions are oriented towards making code easy to understand and robust to refactoring, and why something works (or doesn't work) they way it does always has some solid, fairly simple underlying reason – be it technical or theoretical.
It's just that ensuring correctness requires spelling out more details than other languages force upon the programmer, so this may come across as unusual. Once you get into the flow, however, you'll come to appreciate it.
To add to @kpreid's answer: as far as the standard library is concerned, a large part of all functions in Rust are methods or trait methods. There are few free-standing functions, too, most notably perhaps a handful in
std::iter, but other than that, you can easily tackle:
methods only once you take a look at the type they are defined on. For example for utility functions involving
String, you'd just go through the documentation page of the
String type - the side bar listing app method names is a good first thing to skim through, and then you can read anything that sounds interesting or useful, to learn about more and more of them.
and traits, you should not forget either. (Perhaps after you've come far enough in the book to cover what traits are in the first place), it can be useful to have a good overview over the traits the standard library offers. To cover them all, you could e. g. refer to this article. API offered via traits can often be easy to miss, so when looking at a type, its trait implementations (also visible compactly in the side-bar) can be very important, too, especially for operator overloading, or
Index traits, which often pose crucial API of a type that implements them - also
From implementations can be the main way to construct them for certain types, and
Iterator-related traits can be important and easy to miss functionality, too, particularly
Extend, and the methods they allow for (that is,
iterator_expression.collect()-compatibility; and the
.extend(…) method, particularly for a type like
.concat(…) might be a lot easier to find, but “weirder” in that it takes its second argument by mutable reference)
Also, it can be good to look at the contents of the prelude to learn about the very most important types and traits. In general, it's a good idea, not to forget that module-level documentation exists. For example
std::collections is a very good read, too.
I have also taken the same starting route as you have. After "The Book", I started looking at what I want to know.
For example, databases with MySQL and PostgreSQL, for this, I have come across crate sqlx, among others, I will stick to learning this crate.
Then I want to learn web, I am learning actix-web currently.
We will need to know about logging, I am in the process of learning tracing-appender.
The one thing I have realised so far about Rust is that, like NodeJS and Python, there are plenty of crates for any particular area. For example, there are a lot of web frameworks. Sometimes I actually feel overwhelmed and dizzy. I will do some initial reading, read comparisons etc... then decide on what crate I should learn.
We all learn differently, this is how I do my studies. And as I have learned something, I also write about it. I have my own Wordpress and GitHub.io pages: I write for myself, so that I forgot, I would have something to go back to.
Good luck and enjoy your Rust journey... If you happen to feel overwhelmed, I can assure you that is normal
highly recommended to join the discord community server
What are your interests in the "real world", outside of programming?
Maybe there is some piece of software your "real world" interest is missing?
What helped me learn rust was having a desire to create a specific program for myself. My desire to create what I wanted to create was a great motivator for my learning.
If pretty patterns do it for you..(they do it for me) try reading and modifying the code to the egui fractal clock or minifb julia examples.
Get frustrated by errors.