I’m learning a bit of Rust and starting this topic in case anyone is interested in discussing Rust or wants to help each other out with learning the language.
No need to be a programmer, anything to do with Rust is relevant to this topic including n00b questions. We can always create extra topics if needed, or maybe start a developer focused topic in the Dev forum.
What is Rust?
Rust is the programming language used to create the core of the SAFE Network, and was chosen because it is designed for building secure, reliable code in ways that avoid bugs and make difficult things easier to do well.
Official Rust Resources
Governance
- Rust Foundation - website and announcement 9th Feb 2021
Using Rust
- Rust-Lang (website) is a good place to start. Lots of good resources and answers to your early questions can be found here, along with links to lessons, examples, tools etc.
-
The Rust Programming Language (book).
An excellent tutorial style walk through all the features of Rust, free online and available in print. -
Asynchronous Programming in Rust (book). How to use Rust’s asynchronous programming features (
async
,await
etc.) - The Rust Standard Library (web reference)
Contributing to Rust
- Rust Forge (website) provides supplementary documentation for members and contributors of the Rust programming language
- Rustc Dev Guide (website) provides documentation on how to contribute to the Rust compiler
Other Resources
Programming Books
This section is not just books based on Rust but any programming books you’ve personally found beneficial and would recommend to folks new to programming, as well as wanting to improve their Rust skills.
- The C Programming Language, by Kernighan and Ritchie.
- Rust Design Patterns - free online.
Error Handling
Error handling is important to grasp early on and doesn’t get good coverage in the official resources, so I encourage everyone to not skip this or leave it too long before you get to grips with it. Otherwise you’ll likely end up writing dodgy code without even realising, because almost all the example snippets lead you towards that anti-pattern. David has given some tips and encouragement in Rust error handling for production and test and a few good getting started resources are listed below.
Contemporary recommendations seem consistently to be the anyhow crate for apps and thiserror for libraries rather than error-chain (old) or failure (deprecated). Here are some 2019-2020 sources:
-
Study of std::io::Error is a well written and helpful explanation of how to design good error handling by examining
std::io::Error
and the thinking behind its design (October 2020, blog) -
Rust: Structuring and handling errors in 2020 (blog)
This is an excellent tutorial on the state of the art and a great overview of anyhow and thiserror. Also see the linked Reddit discussion about hand coding in order to avoid needing anyhow and the compilation time savings that can bring. - Idiomatic error handling and error chaining (July 2020, Rust forum)
- Error handling survey (November 2019, blog)
- Error Handling (Rust book)
Async, Futures and Concurrency
- Async programming in Rust with async-std (book). An alternative book on asynchronous programming in Rust.
- Rust concurrency patterns: regretless concurrency? (blog post) by Gregory Terzian, a core team member of the Servo browser engine. A blog post about higher level concurrency concepts in Rust.
- Rust Atomics and Locks (book)
Performance
- The Rust Performance Book (book): A book about several ways to optimize performance of your Rust code.
Other Tools
IDEs
- VSCode/VSCodium works well as an integrated development environment with syntax highlighting, language and library reference using ‘intellisense’, debugger, clippy linter, and code formatter. See using VS Code with Rust.
Testing
- Pretty assertions: Prints pretty diffs in your assertions
Benchmarking
- Criterion: A microbenchmarking library
Share What You Are Doing With Rust
I’d love to hear from anyone about their adventures with Rust! Please post as little or as much as you like on this topic about what you are up to, or are thinking about doing:
- might be an idea for an app you are figuring out
- maybe you’re reading something
- maybe you are trying to understand something that just doesn’t make sense yet
- maybe you are working on a Maidsafe issue
- or building a simple game for the hell of it
- maybe there’s a particular area that you are interested in, such as concurrent or parallel compassion
- or tell use what you’ve done recently, hope to do soon etc
- anything really
What are you up to, or thinking about with Rust?
This topic is a Wiki so anyone can add resources to this post.