Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Network Programming with Rust

You're reading from  Network Programming with Rust

Product type Book
Published in Feb 2018
Publisher Packt
ISBN-13 9781788624893
Pages 278 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Abhishek Chanda Abhishek Chanda
Profile icon Abhishek Chanda
Toc

Error handling

One of Rust's major goals is enabling the developer to write robust software. An essential component of this is advanced error handling. In this section, we will take a deeper look at how Rust does error handling. But before that, let's take a detour and look at some type theory. Specifically, we are interested in algebraic data types (ADT), types formed by combining other types. The two most common ADTs are sum and product types. A struct in Rust is an example of a product type. This name derives from the fact that given a struct, the range of its type is essentially the Cartesian product of the ranges of each of its components, since an instance of the type has values for all of its constituent types. In contrast, a sum type is when the ADT can assume the type of only one of its constituents. An example of this is an enum in Rust. While similar to enums...

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}