implement AtomicStorage for Optionals of RawRepresentable types
An example I wrote a while back needs atomics both for a RawRepresentable type and its Optional. This particular combination of functionality was missing from the package.
This PR defines an implementation of AtomicStorage for this case:
public struct AtomicOptionalRawRepresentableStorage<Wrapped>: AtomicStorage
where Wrapped: RawRepresentable,
Wrapped.RawValue: AtomicOptionalWrappable {
// ...
}
A RawRepresentable type can semi-automatically conform to AtomicOptionalWrappable by declaring
(via typealias) that its AtomicOptionalRepresentation is AtomicOptionalRawRepresentableStorage<Self>.
Checklist
- [x] I've read the Contribution Guidelines
- [x] My contributions are licensed under the Swift license.
- [x] I've followed the coding style of the rest of the project.
- [ ] I've added tests covering all new code paths my change adds to the project (if appropriate).
- [x] I've verified that my change does not break any existing tests.
- [x] I've updated the documentation if necessary.
I don't have complete tests yet, but thought I should check in for feedback anyway.
I suspect testing will uncover an issue with the current definition of RawRepresentable.AtomicOptionalRepresentation, but let's land this on current main before tackling that.