logo资料库

Rust Cookbook.pdf

第1页 / 共558页
第2页 / 共558页
第3页 / 共558页
第4页 / 共558页
第5页 / 共558页
第6页 / 共558页
第7页 / 共558页
第8页 / 共558页
资料共558页,剩余部分请下载后查看
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Getting ready
How to do it…
How it works…
There's more…
See also
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Let us Make System Programming Great Again
Introduction
Setting up Rust in Linux and macOS
Getting ready
How to do it...
Uninstalling Rust
Rust's compiler version
Advanced installation options
Troubleshooting
How it works...
Setting up Rust in Windows
Getting ready
How to do it...
How it works...
Creating your first Rust program
Getting ready
How to do it...
How it works...
Defining a variable assignment
Getting ready
How to do it...
How it works...
Setting up Boolean and the character types
Getting ready
How to do it...
How it works...
Controlling decimal points, number formats, and named arguments
Getting ready
How to do it...
How it works...
Performing arithmetic operations
Getting ready
How to do it...
How it works...
Defining mutable variables
Getting ready
How to do it...
How it works...
Declaring and performing string operations
Getting ready
How to do it...
How it works...
Declaring arrays and using slices in Rust
Getting ready
How to do it...
How it works...
Declaring vectors in Rust
Getting ready
How to do it...
How it works...
Declaring tuples in Rust
Getting ready
How to do it...
How it works...
Performing calculations on two numbers
Getting ready
How to do it...
How it works...
Advanced Programming with Rust
Introduction
Defining an expression
Getting ready
How to do it...
How it works...
Defining constants
Getting ready
How to do it...
How it works...
Performing variable bindings
Getting ready
How to do it...
How it works...
Performing type casting in Rust
Getting ready
How to do it...
How it works...
Decision-making with Rust
Getting ready
How to do it...
How it works...
Looping operations in Rust
Getting ready
How to do it...
How it works...
Defining the enum type
Getting ready
How to do it...
How it works...
Defining closures
Getting ready
How to do it...
How it works...
Performing pointer operations in Rust
Getting ready
How to do it...
How it works...
Defining your first user-defined data type
Getting ready
How to do it...
How it works...
Adding functionality to the user-defined data type
Getting ready
How to do it...
How it works...
Similar functionality for different data type
Getting ready
How to do it...
How it works...
Deep Diving into Cargo
Introduction
Creating a new project using Cargo
Getting ready
How to do it...
How it works...
Downloading an external crate from crates.io
Getting ready
How to do it...
How it works...
Working on existing Cargo projects
Getting ready
How to do it...
How it works...
Running tests with Cargo
Getting ready
How to do it...
How it works...
Configuration management of the project
Getting ready
How to do it...
How it works...
Building the project on the Travis CI
Getting ready
How to do it...
How it works...
Uploading to crates.io
Getting ready
How to do it...
How it works...
Creating Crates and Modules
Introduction
Defining a module in Rust
Getting ready
How to do it...
How it works...
Building a nested module
Getting ready
How to do it...
How it works...
Creating a module with struct
Getting ready
How to do it...
How it works...
Controlling modules
Getting ready
How to do it...
How it works...
Accessing modules
Getting ready
How to do it...
How it works...
Creating a file hierarchy
Getting ready
How to do it...
How it works...
Building libraries in Rust
Getting ready
How to do it...
How it works...
Calling external crates
Getting ready
How to do it...
How it works...
Deep Dive into Parallelism
Introduction
Creating a thread in Rust
Getting ready
How to do it...
How it works...
Spawning multiple threads
Getting ready
How to do it...
How it works...
Holding threads in a vector
Getting ready
How to do it...
How it works...
Sharing data between threads using channels
Getting ready
How to do it...
How it works...
Implementing safe mutable access
Getting ready
How to do it...
How it works...
Creating child processes
Getting ready
How to do it...
How it works...
Waiting for a child process
Getting ready
How to do it...
How it works...
Making sequential code parallel
Getting ready
How to do it...
How it works...
Efficient Error Handling
Introduction
Implementing panic
Getting ready
How to do it...
How it works...
Implementing Option
Getting ready
How to do it...
How it works...
Creating map combinator
Getting ready
How to do it...
How it works...
Creating and_then combinator
Getting ready
How to do it...
How it works...
Creating map for the Result type
Getting ready
How to do it...
How it works...
Implementing aliases
Getting ready
How to do it...
How it works...
Handling multiple errors
Getting ready
How to do it...
How it works...
Implementing early returns
Getting ready
How to do it...
How it works...
Implementing the try! macro
Getting ready
How to do it...
How it works...
Defining your own error types
Getting ready
How to do it...
How it works...
Implementing the boxing of errors
Getting ready
How to do it...
How it works...
Hacking Macros
Introduction
Building macros in Rust
Getting ready
How to do it...
How it works...
Implementing matching in macros
Getting ready
How to do it...
How it works...
Playing with common Rust macros
Getting ready
How to do it...
How it works...
Implementing designators
Getting ready
How to do it...
How it works...
Overloading macros
Getting ready
How to do it...
How it works...
Implementing repeat
Getting ready
How to do it...
How it works...
Implementing DRY
Getting ready
How to do it...
How it works...
Integrating Rust with Other Languages
Introduction
Calling C operations from Rust
Getting ready
How to do it...
How it works...
Calling Rust commands from C
Getting ready
How to do it...
How it works...
Calling Rust operations from Node.js apps
Getting ready
How to do it...
How it works...
Calling Rust operations from Python
Getting ready
How to do it...
How it works...
Writing a Python module in Rust
Getting ready
How to do it...
How it works...
Web Development with Rust
Introduction
Setting up a web server
Getting ready
How to do it...
How it works...
Creating endpoints
Getting ready
How to do it...
How it works...
Handling JSONRequests
Getting ready
How to do it...
How it works...
Building custom error handlers
Getting ready
How to do it...
How it works...
Hosting templates
Getting ready
How to do it...
How it works...
Advanced Web Development in Rust
Introduction
Setting up the API
Getting ready
How to do it...
How it works...
Saving user data in MongoDB
Getting ready
How to do it...
Fetching user data
Getting ready
How to do it...
How it works...
Deleting user data
Getting ready
How to do it...
How it works...
Advanced Rust Tools and Libraries
Introduction
Setting up rustup
Getting ready
How to do it...
How it works...
Setting up rustfmt
Getting ready
How to do it...
How it works...
Setting up rust-clippy
Getting ready
How to do it...
How it works...
Setting up and testing with Servo
Getting ready
How to do it...
How it works...
Generating random numbers
Getting ready
How to do it...
How it works...
Writing lines to a file
Getting ready
How to do it...
How it works...
Parsing unstructured JSON
Getting ready
How to do it...
How it works...
Parsing URL from a string
Getting ready
How to do it...
How it works...
Decompressing a tarball
Getting ready
How to do it...
How it works...
Compressing a directory to a tarball
Getting ready
How to do it...
How it works...
Finding file extensions recursively
Getting ready
How to do it...
How it works...
Download from finelybook www.finelybook.com Rust Cookbook Learn to build blazingly fast and safe real-world applications using the Rust programming language 2
Download from finelybook www.finelybook.com Vigneshwer Dhinakaran BIRMINGHAM - MUMBAI 3
Download from finelybook www.finelybook.com < html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> 4
Download from finelybook www.finelybook.com Rust Cookbook Copyright © 2017 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: July 2017 Production reference: 1260717 Published by Packt Publishing Ltd. 5
Download from finelybook www.finelybook.com Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78588-025-4 www.packtpub.com 6
Download from finelybook www.finelybook.com Credits Author Vigneshwer Dhinakaran Reviewer Pradeep R Copy Editor Muktikant Garimella Gladson Monteiro Project Coordinator Ulhas Kambali Commissioning Editor Proofreader 7
Download from finelybook www.finelybook.com Aaron Lazar Safis Editing Acquisition Editor Denim Pinto Indexer Rekha Nair Content Development Editor Vikas Tiwari Graphics Abhinash Sahu Technical Editor Diwakar Shukla Production Coordinator Melwyn Dsa 8
分享到:
收藏