ENGLISH

Mastering Rust

Book information

Publisher
Packt Publishing
Year
2017
ISBN
9781785881374, 178588137X, 978-1-78588-530-3, 1483863182
Language
english
Format
EPUB
Filesize
5 MB (5171551 bytes)
Pages
\0
Time added
2019-09-25 00:07:30

Description

Discover the powerful, hidden features of Rust you need to build robust, concurrent, and fast applicationsAbout This Book* Learn how concurrency works in Rust and why it is safe* Get to know the different philosophies of error handling and how to use them wisely* After reading this book, you will be able to migrate your legacy C or C++ application to a Rust environmentWho This Book Is ForThe target audience would be readers having knowledge of other programming languages and are able to work fluently in the operating system of their choice, be it Linux, OS X or Windows. Since Rust is a rather new language, they are interested in programming beyond simply using it for work. The book focuses on intermediate and advanced features of Rust. What You Will Learn* Implement unit testing patterns with the standard Rust tools* Get to know the different philosophies of error handling and how to use them wisely* Appreciate Rust's ability to solve memory allocation problems safely without garbage collection* Get to know how concurrency works in Rust and use concurrency primitives such as threads and message passing* Use syntax extensions and write your own* Create a Web application with Rocket* Use Diesel to build safe database abstractionsIn DetailIf concurrent programs are giving you sleepless nights, Rust is your go-to language. Being one of the first ever comprehensive books on Rust, it is filled with real-world examples and explanations, showing you how you can build scalable and reliable programs for your organization. We'll teach you intermediate to advanced level concepts that make Rust a great language. Improving performance, using generics, building macros, and working with threads are just some of the topics we'll cover. We'll talk about the official toolsets and ways to discover more. The book contains a mix of theory interspersed with hands-on tasks, so you acquire the skills as well as the knowledge. Since programming cannot be learned by just reading, we provide exercises (and solutions) to hammer the concepts in. After reading this book, you will be able to implement Rust for your enterprise project, deploy the software, and will know the best practices of coding in Rust. Style and approachThis book is your one stop guide to the Rust programming language and covers advanced-level concepts in a detailed manner using real-world examples.  Read more... Abstract: Discover the powerful, hidden features of Rust you need to build robust, concurrent, and fast applicationsAbout This Book* Learn how concurrency works in Rust and why it is safe* Get to know the different philosophies of error handling and how to use them wisely* After reading this book, you will be able to migrate your legacy C or C++ application to a Rust environmentWho This Book Is ForThe target audience would be readers having knowledge of other programming languages and are able to work fluently in the operating system of their choice, be it Linux, OS X or Windows. Since Rust is a rather new language, they are interested in programming beyond simply using it for work. The book focuses on intermediate and advanced features of Rust. What You Will Learn* Implement unit testing patterns with the standard Rust tools* Get to know the different philosophies of error handling and how to use them wisely* Appreciate Rust's ability to solve memory allocation problems safely without garbage collection* Get to know how concurrency works in Rust and use concurrency primitives such as threads and message passing* Use syntax extensions and write your own* Create a Web application with Rocket* Use Diesel to build safe database abstractionsIn DetailIf concurrent programs are giving you sleepless nights, Rust is your go-to language. Being one of the first ever comprehensive books on Rust, it is filled with real-world examples and explanations, showing you how you can build scalable and reliable programs for your organization. We'll teach you intermediate to advanced level concepts that make Rust a great language. Improving performance, using generics, building macros, and working with threads are just some of the topics we'll cover. We'll talk about the official toolsets and ways to discover more. The book contains a mix of theory interspersed with hands-on tasks, so you acquire the skills as well as the knowledge. Since programming cannot be learned by just reading, we provide exercises (and solutions) to hammer the concepts in. After reading this book, you will be able to implement Rust for your enterprise project, deploy the software, and will know the best practices of coding in Rust. Style and approachThis book is your one stop guide to the Rust programming language and covers advanced-level concepts in a detailed manner using real-world examples Content: Cover Copyright Credits About the Author About the Reviewer www.PacktPub.com Table of Contents Preface Chapter 1: Getting Your Feet Wet What is Rust and why should you care? Installing Rust compiler and Cargo Using rustup.rs A tour of the language and trying it out Constants and variables Loops Compound data Enums and pattern matching Struct methods Using other pieces of code in your module Sequences Exercise -- fix the word counter Summary Chapter 2: Using Cargo to Build Your First Program Cargo and crates Founding a project -- cargo init. Dependencies, building, and runningRunning tests -- cargo test Cargo.toml -- project metadata Editor integrations Final exercise -- starting our project Summary Chapter 3: Unit Testing and Benchmarking Motivation and high-level view Annotations Assert macros Integration or black box tests Documentation tests Benchmarks Integrating with Travis Founding a city-builder game Final exercise -- fixing the tests Summary Chapter 4: Types String types String slices The String type Byte strings Takeaways and tasks Arrays and slices Takeaways and tasks Generic types. Takeaways and tasksTraits and implementations Takeaways and tasks Constants and statics Summary Chapter 5: Error Handling Option and Result Unwrapping Mapping of the Option/Result values Early returns and the try! macro The? operator Panicking Custom errors and the Error trait Exercise Summary Chapter 6: Memory, Lifetimes, and Borrowing LLVM Function variables and the stack The heap Memory safety Ownership Copy trait Function parameters and patterns Borrowing Lifetimes Globals References as function parameters Structs and struct fields Impl signatures. The Drop traitCollector types Box Interior mutability for Copy types -- Cell Interior mutability for move types -- RefCell Practical uses of interior mutability Reference collected memory: Rc and Arc Inspecting memory usage with std::mem Final exercises Summary Chapter 7: Concurrency Problems with concurrency Closures Exercises Threads Exercises Sharing the Copy types Channels Exercises Locks and mutexes Exercises Atomic Rc Exercises The final exercise Summary Chapter 8: Macros Introduction to metaprogramming Dissecting println! Exercises. Debugging macrosMacro keywords block expr ident item meta pat path stmt tt ty Repeating constructs Example -- an HTTP tester Exercises Summary Chapter 9: Compiler Plugins Basics of compiler plugins The minimal compiler plugin Building a compiler plugin via Cargo Code generation as a workaround Aster Linter plugins Macros 1.1 -- custom derives Exercises Summary Chapter 10: Unsafety and Interfacing with Other Languages Unsafety Calling C code from Rust Connecting external libraries to Rust code Creating Ruby extensions with Ruru JavaScript/Node.js and Neon Exercises.

Similar books