the.bay.news

Different behaviour of lifetime dependency for `let` and `var`

Swift Forums
Different behaviour of lifetime dependency for `let` and `var`
The following codes compile successfully: struct B: ~Escapable { @_lifetime(immortal) init() {} func doSomething() {} } struct A: ~Copyable { var b: B { @_lifetime(borrow self) get { return .init() } } consuming func consume() {} } func test() { var a = A() do { let b = a.b b.doSomething() } a.consume() } However, if we change the var a = A() to let a = A(): struct B: ~Escapable { @_lifetime(im...

0 comments

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

No comments yet.