Atnaujinkite slapukų nuostatas

Mastering Rust: A Beginner's Guide [Minkštas viršelis]

  • Formatas: Paperback / softback, 298 pages, aukštis x plotis: 234x156 mm, weight: 453 g, 17 Tables, black and white; 8 Line drawings, black and white; 1 Halftones, black and white; 9 Illustrations, black and white
  • Serija: Mastering Computer Science
  • Išleidimo metai: 11-Nov-2022
  • Leidėjas: CRC Press
  • ISBN-10: 1032319011
  • ISBN-13: 9781032319018
Kitos knygos pagal šią temą:
  • Formatas: Paperback / softback, 298 pages, aukštis x plotis: 234x156 mm, weight: 453 g, 17 Tables, black and white; 8 Line drawings, black and white; 1 Halftones, black and white; 9 Illustrations, black and white
  • Serija: Mastering Computer Science
  • Išleidimo metai: 11-Nov-2022
  • Leidėjas: CRC Press
  • ISBN-10: 1032319011
  • ISBN-13: 9781032319018
Kitos knygos pagal šią temą:
Mastering Rust helps the reader master the powerful Rust programming language for creating stable and versatile applications and projects.

Rust is a dependable and robust programming language that was created with todays needs in mind, which is something that several other scripting languages lack. Rust was developed to provide high functions comparable to those of C and C++, and with a focus on code integrity, which is, arguably, lacking in languages such as C. Rust is a dynamically typed language that emphasizes performance and reliability, particularly in parallelism and storage organization. Rust allows you to store data on the tower or the shedload, and it recognizes the importance of performance optimization. It permits even more effective memory usage as well as faster memory management than most other programming languages in its league.

Make no mistake about it Rust is a programming language with a strong learning curve, and is considered complicated by even the most experienced of developers. The rewards for learning Rust are aplenty, but the learning process itself requires a good deal of determination and hard work.

Nonetheless, Rust aims to provide a secure, concurrent, and practical systems language in ways that other programming languages do not, and this is primarily why Rust is often the preferred choice for building complex and highly stable apps. Rust boasts of advantages over many other programming languages in terms of expressiveness, speed, sound design, and memory storage. Though the language is new and constantly changing with time, there is an excellent opportunity in this field for future employment.

That said, to learn the reliable language that is Rust, you need to have an equally reliable companion guide in your hands, and this is where Mastering Rust comes in.

With Mastering Rust, learning Rust programming language becomes a charm, and will undoubtedly help readers advance their careers.

The Mastering Computer Science series is edited by Sufyan bin Uzayr, a writer and educator with more than a decade of experience in the computing field.
Mastering Computer Science Series Preface xvii
About the Editor xix
Chapter 1 Getting Started with Rust
1(16)
What Exactly Is Rust?
1(8)
Who Rust Is for
2(1)
Rust's Increasing Popularity
2(1)
What Makes the Rust Programming Language Unique?
3(1)
Concurrent Programming Has Been Simplified
4(1)
Some Challenges to Overcome while Programming in Rust
4(1)
What Is the Purpose of Rust?
5(1)
Why Should We Use Rust?
6(1)
Features of Rust
6(3)
Installing Rust
9(1)
Rust in Windows Installation
9(1)
Installing Rust on Linux or macOS
10(1)
Updating and Uninstalling Rust
10(1)
Rust First Program
10(1)
Procedure for Creating, Compiling, and Running the Program
11(1)
Reasons Why Rust Is The Way Of The Future
11(6)
Rust vs. Other Languages
12(1)
Advantages of Rust vs. C++
12(1)
Advantages of Rust vs. Java
12(1)
Advantages of Rust vs. Python
12(1)
Advantages of Rust vs. Go
12(1)
What Makes Rust the Future?
13(1)
Rust Increased the Safety of Memory
13(1)
Rust's Community Is Expanding
14(1)
Rust Is Quick and Adaptable
14(1)
Rust Has a Wide Range of Applications
15(1)
Rust Is Used by Several Large Companies
15(2)
Chapter 2 Common Programming Concepts
17(46)
Variables In Rust
18(1)
Variable Naming Rules
18(1)
Syntax
18(1)
Immutable
19(1)
Mutable
19(1)
Variables and Constants: What Are the Differences?
19(1)
Datatypes In Rust
20(9)
Variable Declaration
21(1)
Scalar Types
21(1)
Integer
22(1)
Illustration
22(1)
Integer Range
22(1)
Integer Overflow
23(1)
Float
23(1)
Automatic-type Casting
24(1)
Number Separator
24(1)
Boolean
24(1)
Character
24(1)
Compound Types
25(1)
Tuple Type
25(1)
Array Type
26(1)
Accessing the Array Elements
27(1)
Invalid Array Element Access
28(1)
Constant In Rust
29(2)
Constant Naming Convention in Rust
29(1)
Constants vs. Variables
29(1)
Variable and Constant Shadowing
30(1)
String In Rust
31(7)
String Literal
31(1)
String Object
32(1)
Syntax
32(1)
String Object - Common Methods
33(1)
Illustration: new()
33(1)
Illustration: to string()
34(1)
Illustration: replace()
34(1)
Illustration: as str()
34(1)
Illustration: push()
35(1)
Illustration: push str()
35(1)
Illustration: len()
35(1)
Illustration: trim()
35(1)
Illustration: split whitespace()
36(1)
Illustration: split() string
36(1)
Illustration: chars()
37(1)
Concatenation of the Strings with + Operator
37(1)
Illustration: String Concatenation
37(1)
Illustration: Type Casting
37(1)
Illustration: Format! Macro
38(1)
Operators In Rust
38(2)
Arithmetic Operators
38(1)
Relational Operators
39(1)
Logical Operators
39(1)
Bitwise Operators
39(1)
Decision-Making In Rust
40(5)
If Statement
40(1)
Syntax
40(1)
If else statement
41(1)
Syntax
41(1)
Flowchart
41(1)
Nested If
42(1)
Syntax
42(1)
Match Statement
43(1)
Syntax
43(1)
Using an "if" statement within a "let" statement
44(1)
Syntax
44(1)
Loops In Rust
45(3)
Loop
45(1)
Syntax
46(1)
Exit from Loops
46(1)
While Loop
46(1)
Syntax
47(1)
Flowchart
47(1)
While Loop Disadvantages
48(1)
For Loop
48(2)
Syntax
48(1)
Distinctions between the While Loop and For Loop
49(1)
Functions In Rust
50(4)
Function Defining
50(1)
Syntax
50(1)
Function Invoking
51(1)
Syntax
51(1)
Illustration
51(1)
Returning Value from a Function
52(1)
Syntax
52(1)
Function with the Parameters
52(1)
Pass by Value
53(1)
Pass by Reference
53(1)
Passing String to a Function
54(1)
Comments In Rust
54(1)
Tuple In Rust
55(1)
Destructing
56(1)
Array In Rust
56(7)
Array Characteristics
57(1)
Array Declaration and Initialization
57(1)
Syntax
57(1)
Illustration: Simple Array
58(1)
Illustration: Array without Data Type
58(1)
Illustration: Default Values
58(1)
Illustration: Array with for Loop
58(1)
Illustration: Using the iter() Function
59(1)
Illustration: Mutable Array
59(1)
Passing Arrays as Parameters to the Functions
59(1)
Illustration: Pass by Value
59(1)
Illustration: Pass by Reference
60(1)
The Array Declaration and Constants
60(3)
Chapter 3 Understanding Ownership
63(26)
What Exactly Is Ownership?
63(13)
The Stack and the Heap
64(1)
Important Ownership Concepts
65(1)
Rules of Ownership
65(1)
Variable Scope
66(1)
String Type
66(1)
Memory and Allocation
67(2)
Ways of Variables and Data Interact: Move
69(3)
Variables and Data Interactions: Clone
72(1)
Stack-Only Data: Copy
73(1)
Ownership and Functions
73(1)
Return Values and Scope
74(2)
References And Borrowing In Rust
76(5)
Why Borrowing?
76(2)
Mutable Reference
78(1)
Restrictions of the Mutable References
78(1)
Dangling References
79(1)
The Referencing Guidelines
80(1)
Slices In Rust
81(8)
Syntax
81(2)
String Slices
83(4)
Literals Are String Slices
87(1)
String Slices as Parameters
87(1)
Other Slices
88(1)
Chapter 4 Using Structs for Related Data
89(22)
What Is The Definition Of A Structure?
89(6)
When the Variables and Fields Have the Same Name, Use the Field init Shorthand
91(1)
Using Struct Update Syntax to Create Instances from Other Instances
92(1)
The Tuple Structs without Named Fields to Create Different Types
93(1)
Structs that Look Like Units but Don't Have Any Fields
93(1)
Ownership of Struct Data
94(1)
Update Syntax
95(8)
An Example of a Structs Program
97(1)
Refactoring with the Tuples
98(1)
Using Structs for Refactoring: Adding Additional Meaning
99(1)
Using Derived Traits to Add Useful Functionality
100(3)
Method Syntax
103(8)
Defining the Methods
104(2)
Methods with More Parameters
106(2)
Associated Functions
108(1)
Multiple impl Blocks
108(3)
Chapter 5 Enums and Pattern Matching
111(18)
Defining An Enum
117(2)
Enum Values
112(4)
The Advantages of the Option Enum over Null Values
116(3)
The Match Control Flow Operator
119(7)
Patterns that Bind to Values
120(2)
Matching with the Option<T>
122(1)
Matches Are Exhaustive
123(1)
Catch-all Patterns and the_Placeholder
124(2)
Concise Control Flow With If Let
126(3)
Chapter 6 Packages, Crates, and Modules
129(20)
Packages And Crates
131(1)
Defining Modules To The Control Scope And Privacy
132(2)
Paths For Referring To An Item In The Module Tree
134(7)
Exposing Paths with pub Keyword
137(2)
Starting Relative Paths with super
139(1)
Making Structs and Enums Public
139(2)
Bringing Paths Into The Scope With The Use Keyword
141(5)
Creating the Idiomatic use Paths
143(1)
Providing New Names with the as Keyword
144(1)
Re-exporting Names with pub use
145(1)
Separating Modules Into Different Files
146(3)
Chapter 7 Error Handling
149(22)
Error Handling
149(5)
Unrecoverable Errors with panic!
150(1)
Unwinding Stack or Aborting in Response to a Panic
150(1)
Using panic! Backtrace
151(3)
Recoverable Errors With The Result
154(10)
Shortcuts for the Panic on Error: unwrap and expect
158(1)
Propagating Errors
159(2)
Shortcut for Propagating Errors: The ? Operator
161(2)
The ? Operator Can Be Used in Functions that Return Result
163(1)
To panic! Or not to panic!
164(7)
Examples, Prototype Code, and Tests
165(1)
Cases in Which We Have More Information than the Compiler
165(1)
Guidelines for the Error Handling
166(1)
Creating the Custom Types for Validation
167(4)
Chapter 8 Generic Types, Traits, and Lifetimes
171(18)
Generic Datatypes
171(13)
In Function Definitions
171(4)
In the Struct Definitions
175(2)
In Method Definitions
177(3)
Performance of Code Using Generics
180(1)
Traits: Defining Shared Behavior
181(1)
Defining a Trait
181(1)
Implementing a Trait on a Type
182(2)
Validating References With Lifetimes
184(5)
Preventing Dangling References with Lifetimes
185(1)
Borrow Checker
186(1)
Generic Lifetimes in the Functions
187(2)
Chapter 9 I/O Project: Building a Command Line Program
189(24)
Accepting The Command Line Arguments
190(2)
Saving the Argument Values in the Variables
192(1)
Reading A File
192(8)
Refactoring to Improve Modularity and Error Handling
194(1)
Separation of Concerns for Binary Projects
195(1)
Extracting the Argument Parser
196(1)
Grouping the Configuration Values
197(1)
Creating a Constructor for the Config
198(1)
Fixing the Error Handling
199(1)
Improving the Error Message
199(1)
Developing The Library's Functionality With The Test-Driven Development
200(3)
Working With The Environment Variables
203(6)
Writing Failing Test for the Case-Insensitive search Function
203(1)
Implementing search case insensitive Function
204(5)
Writing Error Messages To The Standard Error Instead Of Standard Output
209(4)
Checking Where Errors Are Written
209(1)
Printing Errors to the Standard Error
210(3)
Chapter 10 Cargo and crates.io
213(14)
Customizing Builds With The Release Profiles
213(2)
Publishing A Crate To Crates.IO
215(6)
Making Useful Documentation Comments
215(1)
Commonly Used Sections
216(1)
Documentation Comments as Tests
217(1)
Commenting Contained Items
217(1)
Exporting a Convenient Public API with the pub use
218(3)
Setting Up crates.io Account
221(1)
Cargo Workspaces
221(3)
Creating a Workspace
221(2)
Creating the Second Package in the Workspace
223(1)
Installing Binaries From Crates.Io With Cargo Install
224(1)
Extending Cargo With The Custom Commands
225(2)
Chapter 11 Concurrency and State
227(20)
Fearless Concurrency
227(1)
Using Threads To Run Code Simultaneously
228(5)
Creating New Thread with spawn
230(1)
Waiting for All the Threads to Finish Using JoinHandle
231(2)
Using Message Passing To The Transfer Data Between Threads
233(7)
The Channels and Ownership Transference
236(2)
Sending Multiple Values and Seeing the Receiver Waiting
238(1)
Creating Multiple Producers by Cloning the Transmitter
239(1)
Shared-State Concurrency
240(4)
Using Mutexes to Allow Data Access from Only One Thread at a Time
240(1)
API of Mutex<T>
241(1)
Sharing Mutex<T> Between Multiple Threads
242(2)
Extensible Concurrency With Sync And Send Traits
244(3)
Allowing Transference of the Ownership between Threads with Send
244(1)
Allowing Access from the Multiple Threads with Sync
244(1)
Implementing the Send and Sync Manually Is Unsafe
245(2)
Chapter 12 Object-oriented Programming in Rust
247(18)
Implementing An Object-Oriented Design Pattern
247(10)
Defining Post and Creating New Instance in the Draft State
249(1)
Storing the Text of the Post Content
250(1)
Ensuring Content of a Draft Post Is Empty
251(1)
Requesting a Review Changes the State of the Post
251(5)
Trade-offs of the State Pattern
256(1)
Macros
257(8)
Difference between Macros and Functions
258(1)
Declarative Macros with macro rules! for General Metaprogramming
258(2)
Procedural Macros for Generating Code from the Attributes
260(1)
How to Write a Custom derive Macro
261(1)
Attribute-like Macros
262(1)
Function-like Macros
262(3)
Appendix A Keywords 265(4)
Appendix B Operators And Symbols 269(6)
Appendix C Derivable Traits 275(4)
Appraisal 279(6)
Bibliography 285(6)
Index 291
Sufyan bin Uzayr is a writer, coder, and entrepreneur with more than a decade of experience in the industry. He has authored several books in the past, pertaining to a diverse range of topics, ranging from History to Computers/IT.

Sufyan is the Director of Parakozm, a multinational IT company specializing in EdTech solutions. He also runs Zeba Academy, an online learning and teaching vertical with a focus on STEM fields.

Sufyan specializes in a wide variety of technologies, such as JavaScript, Dart, WordPress, Drupal, Linux, and Python. He holds multiple degrees, including ones in Management, IT, Literature, and Political Science.

Sufyan is a digital nomad, dividing his time between four countries. He has lived and taught in universities and educational institutions around the globe. Sufyan takes a keen interest in technology, politics, literature, history, and sports, and in his spare time, he enjoys teaching coding and English to young students.

Learn more at sufyanism.com