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

A noncopyable type `struct Handle: ~Copyable` has a `deinit`. The compiler reports an error on a function that takes `borrowing Handle` and tries `let h2 = handle`. Why is this rejected at the ownership level?

struct Handle: ~Copyable { let fd: Int32 deinit { close(fd) } } func use(_ handle: borrowing Handle) { let h2 = handle // error }