Module 6: References And Borrowing
Check your understanding
A quick multiple-choice check before you move on. Answer every question, then submit to see how you did.
1.A function takes a parameter of type &String and returns s.len(). After you call it with len(&s), what happens to the original binding s?
2.Under Rust's borrowing rules, which combination of references to the same value is allowed to exist at the same time?
3.According to the theory, what is the primary benefit of enforcing the "shared XOR mutable" rule?
4.In Rust you need a value that is "maybe a reference" — sometimes present, sometimes absent. What does the theory recommend, contrasting with C#?
5.The theory contrasts Rust's &mut T with C#'s handling of shared mutable state. Which statement captures that contrast?
Answer every question to submit.