Giter Club home page Giter Club logo

rust-standard-library-cookbook's Introduction

Rust Standard Library Cookbook

This is the code repository for Rust Standard Library Cookbook, published by Packt. It contains all the supporting project files necessary to work through the book from start to finish.

About the Book

Mozilla’s Rust is gaining much attention with amazing features and a powerful library. This book will take you through varied recipes to teach you how to leverage the Standard library to implement efficient solutions.

Instructions and Navigation

All of the code is organized into folders. Each folder starts with a number followed by the application name. For example, Chapter02.

All the code files are present in their respective code folders.

The code will look like the following:

let s = "Hello".to_string();
println!("s: {}", s);
let s = String::from("Hello");
println!("s: {}", s);

This book has been written with and tested for the Rust versions rustc 1.24.1 and rustc 1.26.0-nightly; however, Rust's strong backward compatibility should make it possible for you to use any newer versions for all chapters except the last. Chapter 10, Using Experimental Nightly Features, is working with cutting-edge technology that is expected to improve through ground-breaking changes.

To download the newest Rust version, visit https://rustup.rs/, where you will be able to download a Rust installer for your operating system. It's okay to leave it at the standard settings. Make sure to call rustup default nightly before starting Chapter 10, Using Experimental Nightly Features. Don't worry, you'll be reminded again when it's time.

An active internet connection is required for many recipes, as we will work intensively with crates. These are Rust's way of distributing libraries over the internet, and they are hosted at https://crates.io/.

You might wonder why a book about Rust's standard library, or std for short, uses so much code from outside the std. That's because Rust, in contrast to most other system languages, was designed with strong dependency management in mind from the beginning. It's so easy to pull crates into your code that a lot of specific functionality has been outsourced to officially recommended crates. This helps the core standard library that is distributed with Rust to stay simple and very stable.

The most official group of crates after the std is the nursery (https://github.com/rust-lang-nursery?language=rust). These crates are the standard for many operations and are nearly stable or generic enough to be in the std.

If we can't find a crate for a recipe in the nursery, we look at the crates of the Rust core team members (https://github.com/orgs/rust-lang/people), who put a lot of effort into providing functionality that is missing from the standard library. These crates are not in the nursery because they are usually specific enough that it is not worth allocating too many resources to actively maintaining them.

All the code in this book has been formatted with the newest rustfmt (rustfmt-nightly v0.4.0), which you can optionally download using rustup component add rustfmt-preview and run with cargo fmt. The code on GitHub (https://github.com/jnferner/rust-standard-library-cookbook) is going to be actively maintained and consequently formatted using a newer version of rustfmt, if available. In some cases, this means that the source code line markings can become outdated. It should not be hard to find the code, however, as this shift is usually no greater than two or three lines.

All code has also been checked by Rust's official linter, clippy (https://github.com/rust-lang-nursery/rust-clippy), using version 0.0.187. If you want, you can install it with cargo +nightly install clippy and run it with cargo +nightly clippy. The newest version tends to break quite often though, so don't be surprised if it doesn't work outright.

Some clippy and rustc warnings have been left in the code intentionally. Most of these are either dead code, which happens when we assign a value to a variable to illustrate a concept and then don't need to use the variable anymore, or usage of placeholder names such as foo, bar, or baz, which are used when the exact purpose of a variable is irrelevant to the recipe.

Related Products

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781788623926

rust-standard-library-cookbook's People

Contributors

mehulsingh7 avatar packt-itservice avatar packtutkarshr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.