Chapter 3

How are Sized types different from other types?

Sized means that the size of a type instance is known at runtime, so it doesn't contain a growing data type. For example, str is typically not a sized type  String is. 

How does Clone differ from Copy?

Clone is an explicit call to the clone() function; copy happens implicitly, for example, at assignments. Since Clone is explicitly called, it usually does a deep copy on the underlying data structure. 

What are the main drawbacks of immutable data structures?

Immutable data structures can have worse absolute performances since they can't use the optimizations that regular data structures provide. Additionally, updates on the data that's contained is impossible, making it a very inefficient choice for constantly changing data.

How can applications benefit from immutable data structures?

They implicitly keep track of changes and work well across threads without side effects or the need for locking. 

Think about an immutable list that you want to work on—how would you distribute it across multiple threads?

Depending on the task, it can be split into n chunks, where n is the number of threads. However, this requires you to create n copies of the list—or at least a move per each. Alternatively, the list can be made accessible across threads, providing only the indices to represent the chunks to work on.