Skip to Content
Idiomatic Rust
book

Idiomatic Rust

by Brenden Matthews
September 2024
Intermediate to advanced
256 pages
6h 40m
English
Manning Publications
Content preview from Idiomatic Rust

4 Introductory patterns

This chapter covers

  • Understanding resource acquisition is initialization
  • Passing arguments by value versus reference
  • Using constructors
  • Understanding object member visibility and access
  • Handling errors
  • Global state handling with lazy-static.rs, OnceCell, and static_init

Now we’re ready to dive into some more concrete patterns. We begin by reviewing some elementary topics: RAII, passing values, constructors, and visibility. Then we’ll move on to slightly more complex subjects: error handling and global variables. Although the chapter discusses many topics, it focuses on bite-size patterns, which we’ll use a lot.

This chapter also introduces crates, which are Rust libraries built by the community. The Rust language ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Rust in Action

Rust in Action

Tim McNamara
Effective Rust

Effective Rust

David Drysdale
The Rust Programming Language, 2nd Edition

The Rust Programming Language, 2nd Edition

Steve Klabnik, Carol Nichols

Publisher Resources

ISBN: 9781633437463Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link