Loading…
Ownership, borrowing, lifetimes, traits and error handling without a garbage collector.
Write
pub fn vowel_counts(words: Vec<String>) -> Vec<i64>
Exam scores must be clamped into a range before they are stored. Write
Write
pub fn swap_extremes(values: Vec<i64>) -> Vec<i64>
What is a reference in Rust, and what is the difference between &T
and &mut T? Why would a function take a reference instead of
taking the value itself?
State the borrowing rules the compiler enforces. What kinds of bugs do these rules prevent?
Why does this not compile, and how would you fix it?
let mut scores = vec![10, 20, 30];