February 2021
Intermediate to advanced
394 pages
7h 20m
English
What is the difference between str and String?
A String is a reference stored in the stack that points to str, which is the data stored in the heap.
Why can't string literals be passed through a function (string literal meaning str as opposed to &str)?
Because we do not know the size of a string literal at compile time. A String reference, on the other hand, is fixed, which is why it can be passed through to the function.
How do we access the data belonging to a key in a hash map?
We use the get function, and then unwrap it since the get function merely returns an Option struct.
When a function results in an error, can we handle ...
Read now
Unlock full access