An initializer cannot return a ~Escapable result

I am using swift-binary-parsing and tried to make a non-owning struct with some helper methods for a ParserSpan (a non-escapable, non-copyable type), but got two compiler errors.

import BinaryParsing

struct StringTable: ~Escapable, ~Copyable { // πŸ›‘ An implicit initializer cannot return a ~Escapable result
    let span: ParserSpan // πŸ›‘ The '_read' accessor cannot return a ~Escapable result
}

Adding an explicit initializer also gave an error saying it can’t return a ~Escapable result.

How can these errors be resolved? I am familiar with how ownership and lifetimes work in Rust but not in Swift.

Non-escapable types are behind an experimental flag, try adding -enable-experimental-feature Lifetimesto your project

2 Likes