Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRustlifetime annotations on structsSingle-choice MCQ

Given this struct holding a borrowed slice, which method body fails to compile and why?

struct Cursor<'a> { buf: &'a [u8], pos: usize, } impl<'a> Cursor<'a> { fn rest(&self) -> &[u8] { &self.buf[self.pos..] } fn take(self) -> &'a [u8] { &self.buf[self.pos..] } }