Muutke küpsiste eelistusi

E-raamat: Programming Rust

  • Formaat: 738 pages
  • Ilmumisaeg: 11-Jun-2021
  • Kirjastus: O'Reilly Media
  • Keel: eng
  • ISBN-13: 9781492052548
  • Formaat - EPUB+DRM
  • Hind: 47,96 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Lisa ostukorvi
  • Lisa soovinimekirja
  • See e-raamat on mõeldud ainult isiklikuks kasutamiseks. E-raamatuid ei saa tagastada.
  • Formaat: 738 pages
  • Ilmumisaeg: 11-Jun-2021
  • Kirjastus: O'Reilly Media
  • Keel: eng
  • ISBN-13: 9781492052548

DRM piirangud

  • Kopeerimine (copy/paste):

    ei ole lubatud

  • Printimine:

    ei ole lubatud

  • Kasutamine:

    Digitaalõiguste kaitse (DRM)
    Kirjastus on väljastanud selle e-raamatu krüpteeritud kujul, mis tähendab, et selle lugemiseks peate installeerima spetsiaalse tarkvara. Samuti peate looma endale  Adobe ID Rohkem infot siin. E-raamatut saab lugeda 1 kasutaja ning alla laadida kuni 6'de seadmesse (kõik autoriseeritud sama Adobe ID-ga).

    Vajalik tarkvara
    Mobiilsetes seadmetes (telefon või tahvelarvuti) lugemiseks peate installeerima selle tasuta rakenduse: PocketBook Reader (iOS / Android)

    PC või Mac seadmes lugemiseks peate installima Adobe Digital Editionsi (Seeon tasuta rakendus spetsiaalselt e-raamatute lugemiseks. Seda ei tohi segamini ajada Adober Reader'iga, mis tõenäoliselt on juba teie arvutisse installeeritud )

    Seda e-raamatut ei saa lugeda Amazon Kindle's. 

Systems programming provides the foundation for the world's computation. Developing performance-sensitive code requires a programming language that puts programmers in control of how memory, processor time, and other system resources are used. The Rust systems programming language combines that control with a modern type system that catches broad classes of common mistakes, from memory management errors to interthread data races.

With this practical guide, experienced systems programmers will learn how to successfully bridge the gap between performance and safety using Rust. Jim Blandy, Jason Orendorff, and Leonora Tindall demonstrate how Rust's features put programmers in control over memory consumption and processor use by combining predictable performance with memory safety and trustworthy concurrency.

You'll learn:

  • Rust's fundamental data types and the core concepts of ownership and borrowing
  • Language basics including error handling, crates and modules, structs, and enums
  • How to write flexible, efficient code with traits and generics
  • Rust's key power tools: closures, iterators, and asynchronous programming
  • Collections, strings and text, input and output, concurrency, macros, unsafe code, and interfacing with foreign functions

Preface xv
1 Systems Programmers Can Have Nice Things 1(4)
Rust Shoulders the Load for You
2(1)
Parallel Programming Is Tamed
3(1)
And Yet Rust Is Still Fast
4(1)
Rust Makes Collaboration Easier
4(1)
2 A Tour of Rust 5(44)
rustup and Cargo
6(2)
Rust Functions
8(2)
Writing and Running Unit Tests
10(1)
Handling Command-Line Arguments
11(4)
Serving Pages to the Web
15(7)
Concurrency
22(20)
What the Mandelbrot Set Actually Is
23(5)
Parsing Pair Command-Line Arguments
28(2)
Mapping from Pixels to Complex Numbers
30(2)
Plotting the Set
32(1)
Writing Image Files
33(2)
A Concurrent Mandelbrot Program
35(5)
Running the Mandelbrot Plotter
40(1)
Safety Is Invisible
41(1)
Filesystems and Command-Line Tools
42(7)
The Command-Line Interface
43(2)
Reading and Writing Files
45(1)
Find and Replace
46(3)
3 Fundamental Types 49(30)
Fixed-Width Numeric Types
52(9)
Integer Types
53(3)
Checked, Wrapping, Saturating, and Overflowing Arithmetic
56(2)
Floating-Point Types
58(3)
The bool Type
61(1)
Characters
61(2)
Tuples
63(2)
Pointer Types
65(2)
References
65(1)
Boxes
66(1)
Raw Pointers
66(1)
Arrays, Vectors, and Slices
67(6)
Arrays
67(1)
Vectors
68(3)
Slices
71(2)
String Types
73(5)
String Literals
73(1)
Byte Strings
74(1)
Strings in Memory
74(2)
String
76(1)
Using Strings
77(1)
Other String-Like Types
77(1)
Type Aliases
78(1)
Beyond the Basics
78(1)
4 Ownership and Moves 79(22)
Ownership
81(4)
Moves
85(9)
More Operations That Move
90(1)
Moves and Control Flow
91(1)
Moves and Indexed Content
92(2)
Copy Types: The Exception to Moves
94(4)
Rc and Arc: Shared Ownership
98(3)
5 References 101(32)
References to Values
102(3)
Working with References
105(5)
Rust References Versus C++ References
105(2)
Assigning References
107(1)
References to References
107(1)
Comparing References
108(1)
References Are Never Null
109(1)
Borrowing References to Arbitrary Expressions
109(1)
References to Slices and Trait Objects
110(1)
Reference Safety
110(13)
Borrowing a Local Variable
110(3)
Receiving References as Function Arguments
113(2)
Passing References to Functions
115(1)
Returning References
116(1)
Structs Containing References
117(3)
Distinct Lifetime Parameters
120(1)
Omitting Lifetime Parameters
121(2)
Sharing Versus Mutation
123(7)
Taking Arms Against a Sea of Objects
130(3)
6 Expressions 133(24)
An Expression Language
133(1)
Precedence and Associativity
134(3)
Blocks and Semicolons
137(1)
Declarations
138(2)
if and match
140(2)
if let
142(1)
Loops
142(2)
Control Flow in Loops
144(1)
return Expressions
145(1)
Why Rust Has loop
146(2)
Function and Method Calls
148(1)
Fields and Elements
149(2)
Reference Operators
151(1)
Arithmetic, Bitwise, Comparison, and Logical Operators
151(1)
Assignment
152(1)
Type Casts
153(1)
Closures
154(1)
Onward
154(3)
7 Error Handling 157(16)
Panic
157(3)
Unwinding
158(1)
Aborting
159(1)
Result
160(13)
Catching Errors
160(2)
Result Type Aliases
162(1)
Printing Errors
163(1)
Propagating Errors
164(2)
Working with Multiple Error Types
166(2)
Dealing with Errors That "Can't Happen"
168(1)
Ignoring Errors
169(1)
Handling Errors in main()
169(2)
Declaring a Custom Error Type
171(1)
Why Results?
172(1)
8 Crates and Modules 173(36)
Crates
173(5)
Editions
176(1)
Build Profiles
177(1)
Modules
178(10)
Nested Modules
179(1)
Modules in Separate Files
180(3)
Paths and Imports
183(3)
The Standard Prelude
186(1)
Making use Declarations pub
186(1)
Making Struct Fields pub
186(1)
Statics and Constants
187(1)
Turning a Program into a Library
188(1)
The src/bin Directory
189(2)
Attributes
191(2)
Tests and Documentation
193(9)
Integration Tests
196(1)
Documentation
197(2)
Doc-Tests
199(3)
Specifying Dependencies
202(3)
Versions
202(2)
Cargo.lock
204(1)
Publishing Crates to crates.io
205(2)
Workspaces
207(1)
More Nice Things
208(1)
9 Structs 209(20)
Named-Field Structs
209(3)
Tuple-Like Structs
212(1)
Unit-Like Structs
213(1)
Struct Layout
213(1)
Defining Methods with impl
214(6)
Passing Self as a Box, Rc, or Arc
217(2)
Type-Associated Functions
219(1)
Associated Consts
220(1)
Generic Structs
221(2)
Structs with Lifetime Parameters
223(1)
Deriving Common Traits for Struct Types
224(1)
Interior Mutability
225(4)
10 Enums and Patterns 229(24)
Enums
230(9)
Enums with Data
232(1)
Enums in Memory
233(1)
Rich Data Structures Using Enums
234(2)
Generic Enums
236(3)
Patterns
239(13)
Literals, Variables, and Wildcards in Patterns
242(1)
Tuple and Struct Patterns
243(1)
Array and Slice Patterns
244(1)
Reference Patterns
245(2)
Match Guards
247(1)
Matching Multiple Possibilities
248(1)
Binding with @ Patterns
248(1)
Where Patterns Are Allowed
249(1)
Populating a Binary Tree
250(2)
The Big Picture
252(1)
11 Traits and Generics 253(32)
Using Traits
255(9)
Trait Objects
256(2)
Generic Functions and Type Parameters
258(3)
Which to Use
261(3)
Defining and Implementing Traits
264(7)
Default Methods
265(1)
Traits and Other People's Types
266(2)
Self in Traits
268(1)
Subtraits
269(1)
Type-Associated Functions
270(1)
Fully Qualified Method Calls
271(2)
Traits That Define Relationships Between Types
273(8)
Associated Types (or How Iterators Work)
273(4)
Generic Traits (or How Operator Overloading Works)
277(1)
impl Trait
278(2)
Associated Consts
280(1)
Reverse-Engineering Bounds
281(3)
Traits as a Foundation
284(1)
12 Operator Overloading 285(16)
Arithmetic and Bitwise Operators
286(6)
Unary Operators
289(1)
Binary Operators
290(1)
Compound Assignment Operators
291(1)
Equivalence Comparisons
292(3)
Ordered Comparisons
295(3)
Index and IndexMut
298(2)
Other Operators
300(1)
13 Utility Traits 301(24)
Drop
302(3)
Sized
305(3)
Clone
308(1)
Copy
309(1)
Deref and DerefMut
310(3)
Default
313(2)
AsRef and AsMut
315(1)
Borrow and BorrowMut
316(2)
From and Into
318(3)
TryFrom and Trylnto
321(1)
ToOwned
322(1)
Borrow and ToOwned at Work: The Humble Cow
323(2)
14 Closures 325(20)
Capturing Variables
327(3)
Closures That Borrow
328(1)
Closures That Steal
328(2)
Function and Closure Types
330(2)
Closure Performance
332(1)
Closures and Safety
333(6)
Closures That Kill
334(1)
FnOnce
334(2)
FnMut
336(2)
Copy and Clone for Closures
338(1)
Callbacks
339(4)
Using Closures Effectively
343(2)
15 Iterators 345(46)
The Iterator and Intolterator Traits
347(1)
Creating Iterators
348(8)
iter and iter_mut Methods
348(1)
Intolterator Implementations
349(2)
from_fn and successors
351(2)
drain Methods
353(1)
Other Iterator Sources
354(2)
Iterator Adapters
356(17)
map and filter
356(3)
filter_map and flat_map
359(2)
flatten
361(2)
take and take_while
363(1)
skip and skip_while
363(1)
peekable
364(1)
fuse
365(1)
Reversible Iterators and rev
366(1)
inspect
367(1)
chain
368(1)
enumerate
369(1)
zip
370(1)
by_ref
370(1)
cloned, copied
371(1)
cycle
372(1)
Consuming Iterators
373(12)
Simple Accumulation: count, sum, product
373(1)
max, min
374(1)
max_by, min_by
374(1)
max_by_key, min_by_key
375(1)
Comparing Item Sequences
375(1)
any and all
376(1)
position, rposition, and ExactSizelterator
376(1)
fold and rfold
377(1)
try_fold and try_rfold
378(1)
nth, nth_back
379(1)
last
380(1)
find, rfind, and find_map
380(1)
Building Collections: collect and Fromlterator
381(2)
The Extend Trait
383(1)
partition
383(1)
for_each and try_for_each
384(1)
Implementing Your Own Iterators
385(6)
16 Collections 391(36)
Overview
392(1)
Vec T
393(15)
Accessing Elements
394(2)
Iteration
396(1)
Growing and Shrinking Vectors
396(4)
Joining
400(1)
Splitting
400(3)
Swapping
403(1)
Sorting and Searching
404(2)
Comparing Slices
406(1)
Random Elements
406(1)
Rust Rules Out Invalidation Errors
407(1)
VecDeque T
408(2)
BinaryHeap T
410(1)
HashMap K, V and BTreeMap K, V
411(6)
Entries
415(2)
Map Iteration
417(5)
HashSet T and BTreeSet T
418(1)
Set Iteration
419(1)
When Equal Values Are Different
420(1)
Whole-Set Operations
420(2)
Hashing
422(1)
Using a Custom Hashing Algorithm
423(1)
Beyond the Standard Collections
424(3)
17 Strings and Text 427(44)
Some Unicode Background
428(2)
ASCII, Latin-1, and Unicode
428(1)
UTF-8
428(2)
Text Directionality
430(1)
Characters (char)
430(4)
Classifying Characters
431(1)
Handling Digits
432(1)
Case Conversion for Characters
433(1)
Conversions to and from Integers
434(1)
String and str
434(17)
Creating String Values
435(1)
Simple Inspection
436(1)
Appending and Inserting Text
437(1)
Removing and Replacing Text
438(1)
Conventions for Searching and Iterating
439(1)
Patterns for Searching Text
440(1)
Searching and Replacing
441(1)
Iterating over Text
442(2)
Trimming
444(1)
Case Conversion for Strings
445(1)
Parsing Other Types from Strings
445(1)
Converting Other Types to Strings
446(1)
Borrowing as Other Text-Like Types
447(1)
Accessing Text as UTF-8
447(1)
Producing Text from UTF-8 Data
448(1)
Putting Off Allocation
449(2)
Strings as Generic Collections
451(1)
Formatting Values
451(12)
Formatting Text Values
453(1)
Formatting Numbers
454(2)
Formatting Other Types
456(1)
Formatting Values for Debugging
456(2)
Formatting Pointers for Debugging
458(1)
Referring to Arguments by Index or Name
458(1)
Dynamic Widths and Precisions
459(1)
Formatting Your Own Types
460(2)
Using the Formatting Language in Your Own Code
462(1)
Regular Expressions
463(3)
Basic Regex Use
464(1)
Building Regex Values Lazily
465(1)
Normalization
466(5)
Normalization Forms
467(1)
The unicode-normalization Crate
468(3)
18 Input and Output 471(26)
Readers and Writers
472(14)
Readers
473(2)
Buffered Readers
475(2)
Reading Lines
477(2)
Collecting Lines
479(1)
Writers
480(1)
Files
481(1)
Seeking
482(1)
Other Reader and Writer Types
483(2)
Binary Data, Compression, and Serialization
485(1)
Files and Directories
486(8)
OsStr and Path
486(2)
Path and PathBuf Methods
488(2)
Filesystem Access Functions
490(1)
Reading Directories
491(2)
Platform-Specific Features
493(1)
Networking
494(3)
19 Concurrency 497(42)
Fork-Join Parallelism
499(11)
spawn and join
500(2)
Error Handling Across Threads
502(1)
Sharing Immutable Data Across Threads
503(2)
Rayon
505(3)
Revisiting the Mandelbrot Set
508(2)
Channels
510(13)
Sending Values
511(3)
Receiving Values
514(1)
Running the Pipeline
515(2)
Channel Features and Performance
517(2)
Thread Safety: Send and Sync
519(2)
Piping Almost Any Iterator to a Channel
521(2)
Beyond Pipelines
523(1)
Shared Mutable State
523(15)
What Is a Mutex?
524(2)
Mutex T
526(1)
mut and Mutex
527(1)
Why Mutexes Are Not Always a Good Idea
528(1)
Deadlock
529(1)
Poisoned Mutexes
529(1)
Multiconsumer Channels Using Mutexes
530(1)
Read/Write Locks (RwLock T)
531(1)
Condition Variables (Condvar)
532(1)
Atomics
533(2)
Global Variables
535(3)
What Hacking Concurrent Code in Rust Is Like
538(1)
20 Asynchronous Programming 539(60)
From Synchronous to Asynchronous
541(23)
Futures
542(2)
Async Functions and Await Expressions
544(3)
Calling Async Functions from Synchronous Code: block_on
547(3)
Spawning Async Tasks
550(4)
Async Blocks
554(2)
Building Async Functions from Async Blocks
556(1)
Spawning Async Tasks on a Thread Pool
557(1)
But Does Your Future Implement Send?
558(3)
Long Running Computations: yield_now and spawn_blocking
561(1)
Comparing Asynchronous Designs
562(1)
A Real Asynchronous HTTP Client
563(1)
An Asynchronous Client and Server
564(18)
Error and Result Types
566(1)
The Protocol
567(1)
Taking User Input: Asynchronous Streams
568(2)
Sending Packets
570(1)
Receiving Packets: More Asynchronous Streams
571(2)
The Client's Main Function
573(1)
The Server's Main Function
574(1)
Handling Chat Connections: Async Mutexes
575(3)
The Group Table: Synchronous Mutexes
578(1)
Chat Groups: tokio's Broadcast Channels
579(3)
Primitive Futures and Executors: When Is a Future Worth Polling Again?
582(6)
Invoking Wakers: spawn_blocking
584(2)
Implementing block_on
586(2)
Pinning
588(7)
The Two Life Stages of a Future
588(4)
Pinned Pointers
592(2)
The Unpin Trait
594(1)
When Is Asynchronous Code Helpful?
595(4)
21 Macros 599(26)
Macro Basics
600(7)
Basics of Macro Expansion
601(2)
Unintended Consequences
603(2)
Repetition
605(2)
Built-In Macros
607(2)
Debugging Macros
609(1)
Building the json! Macro
610(12)
Fragment Types
611(4)
Recursion in Macros
615(1)
Using Traits with Macros
615(2)
Scoping and Hygiene
617(3)
Importing and Exporting Macros
620(2)
Avoiding Syntax Errors During Matching
622(1)
Beyond macro_rules!
623(2)
22 Unsafe Code 625(38)
Unsafe from What?
626(2)
Unsafe Blocks
628(1)
Example: An Efficient ASCII String Type
629(2)
Unsafe Functions
631(2)
Unsafe Block or Unsafe Function?
633(1)
Undefined Behavior
634(2)
Unsafe Traits
636(2)
Raw Pointers
638(20)
Dereferencing Raw Pointers Safely
641(1)
Example: RefWithFlag
642(2)
Nullable Pointers
644(1)
Type Sizes and Alignments
645(1)
Pointer Arithmetic
645(2)
Moving into and out of Memory
647(4)
Example: GapBuffer
651(6)
Panic Safety in Unsafe Code
657(1)
Reinterpreting Memory with Unions
658(3)
Matching Unions
661(1)
Borrowing Unions
661(2)
23 Foreign Functions 663
Finding Common Data Representations
664(4)
Declaring Foreign Functions and Variables
668(1)
Using Functions from Libraries
669(4)
A Raw Interface to libgit2
673(6)
A Safe Interface to libgit2
679(11)
Conclusion
690
Index 69
Jim Blandy has been programming since 1981, and writing Free software since 1990. He has been the maintainer of GNU Emacs and GNU Guile, and a maintainer of GDB, the GNU Debugger. He is one of the original designers of the Subversion version control system. Jim now works for Mozilla on Firefox's web developer tools. Jason Orendorff hacks C++ for Mozilla, where he is module owner of the JavaScript engine that's in Firefox. He is an active member of the Nashville developer community and an occasional organizer of homegrown tech events. He is interested in grammar, baking, time travel, and helping people learn about complicated topics. Leonora Tindall is a type system enthusiast and software engineer who uses Rust, Elixir, and other advanced languages to build robust and resilient systems software in high-impact areas like healthcare and data ownership. She works on a variety of open source projects, from genetic algorithms that evolve programs in strange languages to the Rust core libraries and crate ecosystem, and enjoys the experience of contributing to supportive and diverse community projects.