Most common Rust constructs

#1

Hi,
What are the most common Rust constructs that are essential to every Rust programmer. The stuff that gets used in most typical Rust programs.

0 Likes

#2

The Rust book goes through all the really essential constructs.

There are small useful things like Option.as_ref(), and a bunch of other helper methods on Option and Result.

You’ll find combo of Rc<RefCell<T>> or Arc<Mutex<T>> used often, especially if you’re implementing a design pattern (like linked lists) from another language that’s more relaxed about references and mutability.

I’m collecting them here: https://octodon.social/@rust?max_id=99049070528284281

5 Likes

#3

There’s an in-progress list of Rust Patterns you might find useful! Similar, but slightly different are:

  • Rust by Example, a collection of examples for the purpose of learning Rust
  • the Rust Cookbook that organizes examples by the task you want to accomplish
  • API guidelines, most relevant if you’re writing a library rather than an application

Hope those help!

7 Likes

#4

Thank you @kornel and @carols10cents, just what I needed.

1 Like