Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Hands-On Functional Programming in Rust

You're reading from   Hands-On Functional Programming in Rust Build modular and reactive applications with functional programming techniques in Rust 2018

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781788839358
Length 249 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Andrew Johnson Andrew Johnson
Author Profile Icon Andrew Johnson
Andrew Johnson
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
1. Functional Programming – a Comparison FREE CHAPTER 2. Functional Control Flow 3. Functional Data Structures 4. Generics and Polymorphism 5. Code Organization and Application Architecture 6. Mutability, Ownership, and Pure Functions 7. Design Patterns 8. Implementing Concurrency 9. Performance, Debugging, and Metaprogramming 1. Assessments 2. Other Books You May Enjoy Index

Performance, Debugging, and Metaprogramming


  1. How is release mode different from debug mode?

That depends on your Cargo configuration. By default, there are several compiler flags that have different default values in release versus debug mode. One such flag is the opt-level that gets sent to the llvm code generation—the default debug opt-level is 2, and the default release opt-level is 3. These defaults can be changed in Cargo.toml.

  1. How long will an empty loop take to run?

Test it out. Otherwise, it is hard to say for sure on every platform. loop will always be an infinite loop. while true should maybe also be an infinite loop, but will generate a warning. for _ in 0..99999999 {} will be removed at opt-level 3 but not opt-level 2.

  1. What is linear time in Big O notation?

Linear time is O(n) time.

  1. Name a function that grows faster than exponential growth.

Factorial O(n!) grows faster than exponential growth.

  1.  What is faster, a disk read or a network read?

Measure it. There are many physical factors to consider here.

  1. How would you return a Result with multiple error conditions?

Rust recommends using enum types to describe multiple error conditions. Being lazy, you could also use the std::any::Any type.

  1. What is a token tree?

A token tree is a tree data structure containing tokens. As a result of Rust lexing, (...), [...], and {...} token groups will become their own branches.

  1. What is an Abstract Syntax Tree?

An abstract syntax tree is like a token tree but it has a strict structure such that only well-formed (Rust) code can be represented by it.

  1. Why do procedural macros need to be compiled separately?

Procedural macros are written with normal Rust code. To be used in compilation, procedural macros need to have already been compiled.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images