April 2026
Intermediate
631 pages
16h 20m
English
In this section, we’ll provide some practice questions to help reinforce your learning. The exercise questions cover almost all the concepts introduced in the chapter. Solutions to each exercise will follow in Section 4.8.
Fix the compilation errorConsider the following code snippet:
fn main() { let s1: String = String::from("this is me, "); let s2: &str = "Nouman"; some_function(s1, s2); // Something is wrong here println!("{} {}", s1, s2);}fn some_function(a1: String, a2: &str) { println!("{} {}", a1, a2);}
Identify and correct the issue causing the compilation error. Ensure that the program compiles and runs successfully while maintaining proper ownership and borrowing rules.
Ownership in a loopReview the following ...
Read now
Unlock full access