售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Title Page
Copyright and Credits
Hands-On Functional Programming in Rust
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the author
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Reviews
Functional Programming – a Comparison
Technical requirements
Reducing code weight and complexity
Making generics more generic
Functions as values
Iterators
Compact legible expressions
Strict abstraction means safe abstraction
Scoped data binding
Algebraic datatypes
Mixing object-oriented programming and functional programming
Improving project architecture
File hierarchy, modules, and namespace design
Functional design patterns
Metaprogramming
Summary
Questions
Further reading
Functional Control Flow
Technical requirements
Designing the program
Gathering project requirements
Architecting a code map from requirements
Creating a Rust project
Writing stubs for each program requirement
Implementing program logic
Filling in the blanks
Parsing input and storing as building description and floor requests
Updating location, velocity, and acceleration
If the next floor request in the queue is satisfied, then remove it from the queue
Adjusting motor control to process the next floor request
Printing real-time statistics
Printing summary
Breaking down long segments into components
Searching for abstractions
Writing tests
Unit testing
Integration testing
Summary
Questions
Functional Data Structures
Technical requirements
Adjusting to changing the scope of the project
Gathering new project requirements
Architecting a change map from requirements
Translating expectations into requirements
Translating requirements into a change map
Mapping requirements directly to code
Writing the physics simulator
Writing the motor controller
Writing the executable to run a simulation
Writing the executable to analyze a simulation
Running simulations and analyzing data
Summary
Questions
Generics and Polymorphism
Technical requirements
Staying productive during downtime
Learning about generics
Investigating generics
Investigating parametric polymorphism
Investigating generalized algebraic datatypes
Investigating parametric lifetimes
Defining lifetimes on ground types
Defining lifetimes on generic types
Defining lifetimes on traits
Defining lifetime subtyping
Investigating parametric types
Applying parameterization concepts
Parameterizing data
Parameterizing functions and trait objects
Parametric traits and implementations
Summary
Questions
Code Organization and Application Architecture
Technical requirements
Shipping a product without sacrificing quality
Reorganizing the project
Planning content of files by type
Organizing the motor_controllers.rs module
Organizing the buildings.rs module
Planning content of files by purpose
Organizing the motion_controllers.rs module
Organizing the trip_planning.rs module
Organizing the elevator_drivers.rs module
Planning content of files by layer
Organizing the physics.rs module
Organizing the data_recorder.rs module
Planning the content of files by convenience
Organizing the simulate_trip.rs executable
Organizing the analyze_trip.rs executable
Organizing the operate_elevator.rs executable
Mapping code changes and additions
Developing code by type
Writing the motor_controllers.rs module
Writing the buildings.rs module
Developing code by purpose
Writing the motion_controllers.rs module
Writing the trip_planning.rs module
Writing the elevator_drivers.rs module
Developing code by layer
Writing the physics.rs module
Writing the data_recorders.rs module
Developing code by convenience
Writing the simulate_trip.rs executable
Writing the analyze_trip.rs executable
Writing the operate_elevator.rs executable
Reflecting on the project structure
Summary
Questions
Mutability, Ownership, and Pure Functions
Technical requirements
Recognizing anti-patterns of ownership
Inspecting the microcontroller drivers
Inspecting the type and trait definitions
Defining the OverrideCode enum
Defining the ErrorCode enum
Defining the AuthorizedSession struct and deconstructor
Authorizing sessions
Checking errors and resetting state
Privileged commands
Normal commands
Querying library and session state
Inspecting the foreign library tests
Issuing override codes
Accessing status information and sessions
Deactivating active sessions
Issuing normal commands
Issuing privileged commands
Denying unauthorized commands
Inspecting the Rust tests
Rust authorization with sessions
Rust sharing session reference
Privileged commands
Unprivileged commands
Denying access to privileged commands
Learning the rules of ownership
When the owner goes out of scope, the value will be dropped
Using immutable data
Fixing the hard-to-reproduce bug
Preventing hard-to-reproduce bugs
Using pure functions
Summary
Questions
Design Patterns
Technical requirements
Using the functor pattern
Using the monad pattern
Using the combinator pattern
Parser combinators
Using the lazy evaluation pattern
Summary
Questions
Implementing Concurrency
Technical requirements
Using subprocess concurrency
Understanding nix fork concurrency
Using thread concurrency
Understanding Send and Sync traits
Using functional design for concurrency
Summary
Questions
Performance, Debugging, and Metaprogramming
Technical requirements
Writing faster code
Compiling with release mode
Doing less work
Optimizing the code that needs it – profiling
For a code rarely executed, performance is not affected
Multiples of small numbers are also small numbers
Measuring first, to optimize it
Putting the fridge next to the computer
Capping the Big O
Constanting no growth
Logarithmic growth
Polynomial growth
Exponential growth
Referencing data is faster
Preventing bugs with defensive coding
Using Option and Result instead of panic!
Using typesafe interfaces instead of stringly typed interfaces
Using the heartbeat pattern for long running processes
Validating input and output
Finding and fixing bugs
Metaprogramming
Summary
Questions
Assessments
Functional Programming – a Comparison
Functional Control Flow
Functional Data Structures
Generics and Polymorphism
Code Organization and Application Architecture
Mutability, Ownership, and Pure Functions
Design Patterns
Implementing Concurrency
Performance, Debugging, and Metaprogramming
Other Books You May Enjoy
Leave a review - let other readers know what you think
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜