Learning the Basics

In this chapter, we will cover the following recipes:

  • Concatenating strings
  • Using the format! macro
  • Providing a default implementation
  • Using the constructor pattern
  • Using the builder pattern
  • Parallelism through simple threads
  • Generating random numbers
  • Querying with regexes
  • Accessing the command line
  • Interacting with environment variables
  • Reading from stdin
  • Accepting a variable number of arguments

Introduction

There are some code snippets and patterns of thought that prove time and again to be the bread and butter of a certain programming language. We will start this book by looking at a handful of such techniques in Rust. They are so quintessential for elegant and flexible code that you will use at least some of them ...

Get Rust Standard Library Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.