Skip to content

Practice Exam 1, Problem 1: Short Questions

Midterm 1 practice exam, problem 1 of 5 · Length: 11:09 · Exercises: 01r_control_flow (Week 1) · 03r_borrowing, with 02r_ownership (Week 2) · 04r_structs_impl (Week 3) · 08r_errors (Week 4) · Answer key: Solutions (PDF)

Four parts, worked on the exam's pages 2 to 6: (a) pgroundup and count_pages by hand, and what happens at usize::MAX; (b) which lines of the PageGuard code fail to compile, and why it can never be Copy; (c) why longest's lifetime rejects the code, and two fixes; (d) read_file without ?, and three calls traced through lookup and read. The answer key's handwriting is written onto the exam page as each step is worked.

Download the video (MP4, 41 MB) · Captions (WebVTT) · All five problems