Async initializer: big yes, need this one all the time.
Codable conformance: eh? I generally don't trust auto-synthesized Codable with non-RawRepresentable enums anyway; it's very weird and never matches any other convention for storing enums in JSON. I can't imagine a situation where I'd want or use it; I'd always end up writing a property wrapper or similar to encode in another way.
For those too lazy to read the enum coding spec, the encoding in JSON would be:
I'm generally a fan of more Result API, and personally use a set of async functions that turn Result into a type of Promise, allowing me to chain sync and async work while preserving error information along the way.
However, I think it's about six years too late to add a Codable conformance. Unlike the new functions, where collisions can be mitigated, there's no way to make this change compatible with existing code. Additionally, the default Codable synthesis for enums is never what anyone would write, so it's only useful in the narrow case where you're persisting a value and don't care about the schema. I'd suggest we don't do anything here.
I also don't understand this point:
None of these additions require writing your own Result type, you can implement the functions and Codable yourself just fine. The community has been doing that this whole time. In fact, I'd say that adding a Codable conformance would actually create more work than not, as users would have to move their conformance to a custom type, as the synthesized conformance wouldn't be compatible with what they had.
That would make it more acceptable, as it's most likely to match what people have already written, but there will still be those cases where it doesn't. I learned this recently when Xcode 16.3b1 added a Codable conformance to CLLocationCoordinate2D (still in beta 2) which broke our decoding, as we weren't using the obvious encoding. Which reminds me...
@ktoso I've been assuming that deploying new protocol conformances was still an issue with the language (and the CLLocationCoordinate2D conformance was causing a linker crash on older OSes last I checked). Has that been solved or am I confusing it with something else? (I seem to recall some type recently had an Equatable conformance added but were unable to back deploy the conformance, leaving only the == implementation available.) So perhaps it's just that the conformance can't be back deployed, even if the requirements can be?
+1 on the async init. I have this method defined in at least three of my projects. It needs the usual isolation parameter as long as SE-0461 is not accepted.
definitely a +1 on the async init part! (I just ran into the issue :>)
for the Codable conformance, generally +1, though others mentioned the default synthesized implementation isn't ideal. I personally am not a Codable expert (I don't have enough knowledge to do a simple implementation), so I think I can't give an opinion on that.