Mutability, Ownership, and Pure Functions
- What does
Rc
stand for?
Rc
stands for Reference Counted.
- What does
Arc
stand for?
Arc
stands for Atomically Reference Counted.
- What is a weak reference?
A weak reference is a reference that is not reference counted or otherwise managed.
- Which superpowers are enabled in unsafe blocks?
In an unsafe block, you can dereference a raw pointer, call an unsafe function or method, access or modify a mutable static variable, or implement and unsafe trait.
- When will an object be dropped?
An object will be dropped when its owner is dropped or goes out of scope.
- What is the difference between lifetimes and ownership?
Lifetimes are a compile-time check. Ownership is a compile-time as well as runtime concept. Both concepts describe the tracking of variables, values, and whether and who uses them.
- How can you be sure that a function is safe?
In Rust, there is no way to declare the absence of unsafe behavior in functions.
- What is memory corruption and how would it affect a program?
There are two types of memory corruption—physical memory corruption and software memory corruption. If your physical memory is corrupted, then you need to replace your hardware. Software memory corruption refers to anything the program has done to destroy the semantic structure of its own program. When memory is corrupted, everything goes wrong; this is one of the hardest classes of bugs to diagnose and treat.