Skip to Content
Rust Web Programming
book

Rust Web Programming

by Maxwell Flitton
February 2021
Intermediate to advanced
394 pages
7h 20m
English
Packt Publishing
Content preview from Rust Web Programming

Assessments

Chapter 1, Quick Introduction to Rust

Question 1

What is the difference between str and String?

Answer

A String is a reference stored in the stack that points to str, which is the data stored in the heap.

Question 2

Why can't string literals be passed through a function (string literal meaning str as opposed to &str)?

Answer

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.

Question 3

How do we access the data belonging to a key in a hash map?

Answer

We use the get function, and then unwrap it since the get function merely returns an Option struct.

Question 4

When a function results in an error, can we handle ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

You might also like

Rust Web Programming - Second Edition

Rust Web Programming - Second Edition

Maxwell Flitton
Rust Web Development

Rust Web Development

Bastian Gruber

Publisher Resources

ISBN: 9781800560819