Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardSwiftownership borrowing consumingSingle-choice MCQ

For this noncopyable type, what does the compiler do with the marked line, and why?

struct FileHandle: ~Copyable { var id: Int consuming func close() {} borrowing func peek() -> Int { id } } func use() { let fh = FileHandle(id: 7) fh.close() // consumes fh _ = fh.peek() // <-- this line }