Result
だとサクッと入れられるし、 async/await
や Typed Throws ですら Result
と比べると相当重いアップデートですし。Result
の Failure == Never
のときに keypath member lookup あると便利そうじゃないですか?@dynamicMemberLookup enum MyResult<Success, Failure: Error> { case success(Success) case failure(Failure) subscript<T>(dynamicMember keyPath: KeyPath<Success, T>) -> T where Failure == Never { switch self { case .success(let value): return value[keyPath: keyPath] } } } struct User { var name: String var age: Int } let user: MyResult<User, Never> = .success(User(name: "Name", age: 42)) print(user.name)