the.bay.news

Lifetime dependencies and subtyping

Swift Forums
Lifetime dependencies and subtyping
When a function returns a non-escapable type that copies the lifetime dependencies of an input, the copy lifetime annotation is used: struct NE: ~Escapable { } @_lifetime(copy ne) func copies(_ ne: borrowing NE) -> NE { return copy ne } Such a function that returns a copy will still type-check, even if the lifetime annotation is replaced with borrow ne or &ne (if the parameter is changed to be taken as inout): @_lifetime(borrow ne) func stillCopies(_ ne: borrowing NE) -> NE { return cop...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.